1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyaddr2_r): Check and

adjust the buffer alignment.
This commit is contained in:
Ulrich Drepper
2009-01-08 00:03:29 +00:00
parent 5846e22fbf
commit df9293cb16
3 changed files with 29 additions and 11 deletions

View File

@@ -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;