12745e
commit 2959eda9272a033863c271aff62095abd01bd4e3
12745e
Author: Arjun Shankar <arjun.is@lostca.se>
12745e
Date:   Tue Apr 21 14:06:31 2015 +0200
12745e
12745e
    CVE-2015-1781: resolv/nss_dns/dns-host.c buffer overflow [BZ#18287]
12745e
12745e
diff --git glibc-2.17-c758a686/resolv/nss_dns/dns-host.c glibc-2.17-c758a686/resolv/nss_dns/dns-host.c
12745e
index b16b0dd..d8c5579 100644
12745e
--- glibc-2.17-c758a686/resolv/nss_dns/dns-host.c
12745e
+++ glibc-2.17-c758a686/resolv/nss_dns/dns-host.c
12745e
@@ -613,7 +613,8 @@
12745e
   int have_to_map = 0;
12745e
   uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct host_data);
12745e
   buffer += pad;
12745e
-  if (__builtin_expect (buflen < sizeof (struct host_data) + pad, 0))
12745e
+  buflen = buflen > pad ? buflen - pad : 0;
12745e
+  if (__builtin_expect (buflen < sizeof (struct host_data), 0))
12745e
     {
12745e
       /* The buffer is too small.  */
12745e
     too_small: