diff options
| author | Florian Weimer <fweimer@redhat.com> | 2021-07-19 07:55:27 +0200 |
|---|---|---|
| committer | Florian Weimer <fweimer@redhat.com> | 2021-07-19 07:56:21 +0200 |
| commit | 276e9822b3402d49a3c9bea713f89dc855812152 (patch) | |
| tree | 1599a1be8b294d39144157e6ac701b19095b8f03 | |
| parent | 4e1d3db1e86804283cd21f3186e06d397284ac70 (diff) | |
| download | glibc-276e9822b3402d49a3c9bea713f89dc855812152.tar.xz glibc-276e9822b3402d49a3c9bea713f89dc855812152.zip | |
resolv: Move ns_name_pton into its own file and into libc
And reformat to GNU style, and eliminate the digits variable.
The symbol was moved using scripts/move-symbol-to-libc.py.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
69 files changed, 229 insertions, 157 deletions
diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h index dcceff823d..c27008b5ff 100644 --- a/include/arpa/nameser.h +++ b/include/arpa/nameser.h @@ -65,7 +65,6 @@ libresolv_hidden_proto (ns_put32) libresolv_hidden_proto (ns_initparse) libresolv_hidden_proto (ns_skiprr) libresolv_hidden_proto (ns_parserr) -libresolv_hidden_proto (ns_name_pton) libresolv_hidden_proto (ns_name_pack) libresolv_hidden_proto (ns_name_compress) libresolv_hidden_proto (ns_sprintrr) @@ -77,6 +76,8 @@ libresolv_hidden_proto (ns_format_ttl) extern __typeof (ns_name_ntop) __ns_name_ntop; libc_hidden_proto (__ns_name_ntop) +extern __typeof (ns_name_pton) __ns_name_pton; +libc_hidden_proto (__ns_name_pton) extern __typeof (ns_name_skip) __ns_name_skip; libc_hidden_proto (__ns_name_skip) extern __typeof (ns_name_uncompress) __ns_name_uncompress; diff --git a/resolv/Makefile b/resolv/Makefile index 3145ddebb7..7839e1fb3c 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -33,6 +33,7 @@ routines := \ inet_ntop \ inet_pton \ ns_name_ntop \ + ns_name_pton \ ns_name_skip \ ns_name_uncompress \ ns_name_unpack \ diff --git a/resolv/Versions b/resolv/Versions index 9e8762f984..770a2b8d6b 100644 --- a/resolv/Versions +++ b/resolv/Versions @@ -26,6 +26,7 @@ libc { } GLIBC_2.9 { ns_name_ntop; + ns_name_pton; ns_name_skip; ns_name_uncompress; ns_name_unpack; @@ -38,6 +39,7 @@ libc { getaddrinfo_a; %endif ns_name_ntop; + ns_name_pton; ns_name_skip; ns_name_uncompress; ns_name_unpack; @@ -50,6 +52,7 @@ libc { __inet_aton_exact; __inet_pton_length; __ns_name_ntop; + __ns_name_pton; __ns_name_skip; __ns_name_uncompress; __ns_name_unpack; diff --git a/resolv/ns_name.c b/resolv/ns_name.c index 35e25cbd83..9f7ca4a506 100644 --- a/resolv/ns_name.c +++ b/resolv/ns_name.c @@ -29,10 +29,6 @@ # define SPRINTF(x) ((size_t)sprintf x) -/* Data. */ - -static const char digits[] = "0123456789"; - /* Forward. */ static int dn_find(const u_char *, const u_char *, @@ -42,127 +38,6 @@ static int labellen(const u_char *); /* Public. */ - -/*% - * Convert an ascii string into an encoded domain name as per RFC1035. - * - * return: - * - *\li -1 if it fails - *\li 1 if string was fully qualified - *\li 0 is string was not fully qualified - * - * notes: - *\li Enforces label and domain length limits. - */ - -int -ns_name_pton(const char *src, u_char *dst, size_t dstsiz) -{ - u_char *label, *bp, *eom; - int c, n, escaped; - char *cp; - - escaped = 0; - bp = dst; - eom = dst + dstsiz; - label = bp++; - - while ((c = *src++) != 0) { - if (escaped) { - if ((cp = strchr(digits, c)) != NULL) { - n = (cp - digits) * 100; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - __set_errno (EMSGSIZE); - return (-1); - } - n += (cp - digits) * 10; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - __set_errno (EMSGSIZE); - return (-1); - } - n += (cp - digits); - if (n > 255) { - __set_errno (EMSGSIZE); - return (-1); - } - c = n; - } - escaped = 0; - } else if (c == '\\') { - escaped = 1; - continue; - } else if (c == '.') { - c = (bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */ - __set_errno (EMSGSIZE); - return (-1); - } - if (label >= eom) { - __set_errno (EMSGSIZE); - return (-1); - } - *label = c; - /* Fully qualified ? */ - if (*src == '\0') { - if (c != 0) { - if (bp >= eom) { - __set_errno (EMSGSIZE); - return (-1); - } - *bp++ = '\0'; - } - if ((bp - dst) > MAXCDNAME) { - __set_errno (EMSGSIZE); - return (-1); - } - return (1); - } - if (c == 0 || *src == '.') { - __set_errno (EMSGSIZE); - return (-1); - } - label = bp++; - continue; - } - if (bp >= eom) { - __set_errno (EMSGSIZE); - return (-1); - } - *bp++ = ( |
