aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-07-15 08:28:50 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-07-15 09:00:27 +0200
commit820bb23ff074db8255217ab01b51f28c96ec76a9 (patch)
tree14bb3922ac81a76d8f2124215682644a4a05e96c
parentee3639e0fe61a3692adf660e04f9e6d56475ff52 (diff)
downloadglibc-820bb23ff074db8255217ab01b51f28c96ec76a9.tar.xz
glibc-820bb23ff074db8255217ab01b51f28c96ec76a9.zip
resolv: Move ns_name_unpack to its own file and into libc
Reformat to GNU style. Avoid out-of-bounds buffer arithmetic. Eliminate the labellen function. 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>
-rw-r--r--include/arpa/nameser.h3
-rw-r--r--resolv/Makefile1
-rw-r--r--resolv/Versions5
-rw-r--r--resolv/ns_name.c81
-rw-r--r--resolv/ns_name_unpack.c115
-rw-r--r--sysdeps/mach/hurd/i386/libc.abilist2
-rw-r--r--sysdeps/mach/hurd/i386/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/alpha/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/arc/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/arc/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/arm/be/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/arm/be/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/arm/le/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/arm/le/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/csky/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/csky/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/hppa/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/hppa/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/i386/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/i386/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/ia64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/ia64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/m68k/coldfire/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/m68k/m680x0/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/be/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/be/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/le/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/le/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/riscv/rv32/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/riscv/rv64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sh/be/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/sh/be/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sh/le/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/sh/le/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/64/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/64/libresolv.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist2
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/libresolv.abilist1
69 files changed, 187 insertions, 115 deletions
diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h
index f1a696514a..2396a43030 100644
--- a/include/arpa/nameser.h
+++ b/include/arpa/nameser.h
@@ -68,7 +68,6 @@ libresolv_hidden_proto (ns_parserr)
libresolv_hidden_proto (ns_name_pton)
libresolv_hidden_proto (ns_name_pack)
libresolv_hidden_proto (ns_name_skip)
-libresolv_hidden_proto (ns_name_unpack)
libresolv_hidden_proto (ns_name_compress)
libresolv_hidden_proto (ns_name_uncompress)
libresolv_hidden_proto (ns_sprintrr)
@@ -80,6 +79,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_unpack) __ns_name_unpack;
+libc_hidden_proto (__ns_name_unpack)
# endif /* !_ISOMAC */
#endif
diff --git a/resolv/Makefile b/resolv/Makefile
index bb16175654..469a9a55ae 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -33,6 +33,7 @@ routines := \
inet_ntop \
inet_pton \
ns_name_ntop \
+ ns_name_unpack \
nsap_addr \
res-close \
res-state \
diff --git a/resolv/Versions b/resolv/Versions
index 4bf1a13d48..9b5c4d9733 100644
--- a/resolv/Versions
+++ b/resolv/Versions
@@ -26,6 +26,7 @@ libc {
}
GLIBC_2.9 {
ns_name_ntop;
+ ns_name_unpack;
}
GLIBC_2.34 {
%if PTHREAD_IN_LIBC
@@ -35,6 +36,7 @@ libc {
getaddrinfo_a;
%endif
ns_name_ntop;
+ ns_name_unpack;
}
GLIBC_PRIVATE {
%if !PTHREAD_IN_LIBC
@@ -45,6 +47,7 @@ libc {
__inet_pton_length;
__res_iclose;
__ns_name_ntop;
+ __ns_name_unpack;
__resolv_context_get;
__resolv_context_get_override;
__resolv_context_get_preinit;
@@ -147,7 +150,6 @@ libresolv {
ns_name_rollback;
ns_name_skip;
ns_name_uncompress;
- ns_name_unpack;
ns_parse_ttl;
ns_parserr;
ns_put16;
@@ -162,7 +164,6 @@ libresolv {
GLIBC_PRIVATE {
__ns_get16;
__ns_get32;
- __ns_name_unpack;
__res_context_hostalias;
__res_context_query;
__res_context_search;
diff --git a/resolv/ns_name.c b/resolv/ns_name.c
index 4990003746..a0d541f110 100644
--- a/resolv/ns_name.c
+++ b/resolv/ns_name.c
@@ -218,87 +218,6 @@ ns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz)
}
/*%
- * Unpack a domain name from a message, source may be compressed.
- *
- * return:
- *\li -1 if it fails, or consumed octets if it succeeds.
- */
-int
-ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
- u_char *dst, size_t dstsiz)
-{
- const u_char *srcp, *dstlim;
- u_char *dstp;
- int n, len, checked, l;
-
- len = -1;
- checked = 0;
- dstp = dst;
- srcp = src;
- dstlim = dst + dstsiz;
- if (srcp < msg || srcp >= eom) {
- __set_errno (EMSGSIZE);
- return (-1);
- }
- /* Fetch next label in domain name. */
- while ((n = *srcp++) != 0) {
- /* Check for indirection. */
- switch (n & NS_CMPRSFLGS) {
- case 0:
- /* Limit checks. */
- if ((l = labellen(srcp - 1)) < 0) {
- __set_errno (EMSGSIZE);
- return(-1);
- }
- if (dstp + l + 1 >= dstlim || srcp + l >= eom) {
- __set_errno (EMSGSIZE);
- return (-1);
- }
- checked += l + 1;
- *dstp++ = n;
- memcpy(dstp, srcp, l);
- dstp += l;
- srcp += l;
- break;
-
- case NS_CMPRSFLGS:
- if (srcp >= eom) {
- __set_errno (EMSGSIZE);
- return (-1);
- }
- if (len < 0)
- len = srcp - src + 1;
- srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
- if (srcp < msg || srcp >= eom) { /*%< Out of range. */
- __set_errno (EMSGSIZE);
- return (-1);
- }
- checked += 2;
- /*
- * Check for loops in the compressed name;
- * if we've looked at the whole message,
- * there must be a loop.
- */
- if (checked >= eom - msg) {
- __set_errno (EMSGSIZE);
- return (-1);
- }
- break;
-
- default:
- __set_errno (EMSGSIZE);
- return (-1); /*%< flag error */
- }
- }
- *dstp = '\0';
- if (len < 0)
- len = srcp - src;
- return (len);
-}
-libresolv_hidden_def (ns_name_unpack)
-strong_alias (ns_name_unpack, __ns_name_unpack)
-