diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-01-08 00:03:29 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2009-01-08 00:03:29 +0000 |
commit | df9293cb169bf848be529381ca43680aa192421e (patch) | |
tree | ed8f2033ae7a6f9aa08d36e708db32deeeb611fe /resolv | |
parent | 5846e22fbfab60c75547d5a619029d297864d86a (diff) | |
download | glibc-df9293cb169bf848be529381ca43680aa192421e.zip glibc-df9293cb169bf848be529381ca43680aa192421e.tar.gz glibc-df9293cb169bf848be529381ca43680aa192421e.tar.bz2 |
* 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.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index b8e513a..a9462ae 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; |