patches/glibc/2.9/120-_nss_dns_gethostbyaddr2_r-check-and-adjust-the-buffer-alignment.patch
branchnewlib
changeset 1365 c4d124ed9f8e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/2.9/120-_nss_dns_gethostbyaddr2_r-check-and-adjust-the-buffer-alignment.patch	Sun Apr 19 16:17:11 2009 +0000
     1.3 @@ -0,0 +1,35 @@
     1.4 +Original patch from: gentoo/src/patchsets/glibc/2.9/0050_all_glibc-_nss_dns_gethostbyaddr2_r-check-and-adjust-the-buffer-alignment.patch
     1.5 +
     1.6 +-= BEGIN original header =-
     1.7 +http://sourceware.org/ml/libc-alpha/2009-01/msg00000.html
     1.8 +
     1.9 +From 8ad7030880eaa18dcabf8e284e79026301fd3fa4 Mon Sep 17 00:00:00 2001
    1.10 +From: Ulrich Drepper <drepper@redhat.com>
    1.11 +Date: Thu, 8 Jan 2009 00:02:38 +0000
    1.12 +Subject: [PATCH] (_nss_dns_gethostbyaddr2_r): Check and adjust the buffer alignment.
    1.13 +
    1.14 +-= END original header =-
    1.15 +
    1.16 +diff -durN glibc-2_9.orig/resolv/nss_dns/dns-host.c glibc-2_9/resolv/nss_dns/dns-host.c
    1.17 +--- glibc-2_9.orig/resolv/nss_dns/dns-host.c	2008-11-12 08:52:20.000000000 +0100
    1.18 ++++ glibc-2_9/resolv/nss_dns/dns-host.c	2009-02-02 22:00:36.000000000 +0100
    1.19 +@@ -364,6 +364,19 @@
    1.20 +   int n, status;
    1.21 +   int olderr = errno;
    1.22 + 
    1.23 ++ uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct host_data);
    1.24 ++ buffer += pad;
    1.25 ++ buflen = buflen > pad ? buflen - pad : 0;
    1.26 ++
    1.27 ++ if (__builtin_expect (buflen < sizeof (struct host_data), 0))
    1.28 ++   {
    1.29 ++     *errnop = ERANGE;
    1.30 ++     *h_errnop = NETDB_INTERNAL;
    1.31 ++     return NSS_STATUS_TRYAGAIN;
    1.32 ++   }
    1.33 ++
    1.34 ++ host_data = (struct host_data *) buffer;
    1.35 ++
    1.36 +   if (__res_maybe_init (&_res, 0) == -1)
    1.37 +     return NSS_STATUS_UNAVAIL;
    1.38 +