about summary refs log tree commit diff
path: root/resolv/ns_name.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-13 11:56:28 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-13 11:56:28 +0200
commitc803cb9b24c6cea15698768e4301e963b98e742c (patch)
tree8b1dfb346ea50ccd7f1da044c65b60bb4b9aee27 /resolv/ns_name.c
parenta7ff1da8239a5f0e1927db9d5310f53cfea97fc2 (diff)
downloadglibc-c803cb9b24c6cea15698768e4301e963b98e742c.tar.gz
glibc-c803cb9b24c6cea15698768e4301e963b98e742c.tar.xz
glibc-c803cb9b24c6cea15698768e4301e963b98e742c.zip
resolv: Support an exactly sized buffer in ns_name_pack [BZ #21359]
This bug did not affect name resolution because those functions
indirectly call ns_name_pack with a buffer which is always larger
than the generated query packet, even in the case of the
longest-possible domain name.
Diffstat (limited to 'resolv/ns_name.c')
-rw-r--r--resolv/ns_name.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/resolv/ns_name.c b/resolv/ns_name.c
index 0d76fe53a6..08a75e2fe0 100644
--- a/resolv/ns_name.c
+++ b/resolv/ns_name.c
@@ -475,7 +475,7 @@ ns_name_pack(const u_char *src, u_char *dst, int dstsiz,
 			goto cleanup;
 		}
 		n = labellen(srcp);
-		if (dstp + 1 + n >= eob) {
+		if (n + 1 > eob - dstp) {
 			goto cleanup;
 		}
 		memcpy(dstp, srcp, n + 1);