summary refs log tree commit diff
path: root/resolv
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-08 00:03:29 +0000
committerUlrich Drepper <drepper@redhat.com>2009-01-08 00:03:29 +0000
commitdf9293cb169bf848be529381ca43680aa192421e (patch)
treeed8f2033ae7a6f9aa08d36e708db32deeeb611fe /resolv
parent5846e22fbfab60c75547d5a619029d297864d86a (diff)
downloadglibc-df9293cb169bf848be529381ca43680aa192421e.tar.gz
glibc-df9293cb169bf848be529381ca43680aa192421e.tar.xz
glibc-df9293cb169bf848be529381ca43680aa192421e.zip
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyaddr2_r): Check and
	adjust the buffer alignment.
Diffstat (limited to 'resolv')
-rw-r--r--resolv/nss_dns/dns-host.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index b8e513a929..a9462ae97a 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2004, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Extended from original form by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -376,6 +376,19 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af,
   int n, status;
   int olderr = errno;
 
+ uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct host_data);
+ buffer += pad;
+ buflen = buflen > pad ? buflen - pad : 0;
+
+ if (__builtin_expect (buflen < sizeof (struct host_data), 0))
+   {
+     *errnop = ERANGE;
+     *h_errnop = NETDB_INTERNAL;
+     return NSS_STATUS_TRYAGAIN;
+   }
+
+ host_data = (struct host_data *) buffer;
+
   if (__res_maybe_init (&_res, 0) == -1)
     return NSS_STATUS_UNAVAIL;