|
|
147e83 |
commit 7cbcdb3699584db8913ca90f705d6337633ee10f
|
|
|
147e83 |
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
|
|
|
147e83 |
Date: Fri Oct 25 10:22:12 2013 +0530
|
|
|
147e83 |
|
|
|
147e83 |
Fix stack overflow due to large AF_INET6 requests
|
|
|
147e83 |
|
|
|
147e83 |
Resolves #16072 (CVE-2013-4458).
|
|
|
147e83 |
|
|
|
147e83 |
This patch fixes another stack overflow in getaddrinfo when it is
|
|
|
147e83 |
called with AF_INET6. The AF_UNSPEC case was fixed as CVE-2013-1914,
|
|
|
147e83 |
but the AF_INET6 case went undetected back then.
|
|
|
147e83 |
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
|
|
|
147e83 |
index e6ce4cf..8ff74b4 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
|
|
|
147e83 |
@@ -197,7 +197,22 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
|
|
|
147e83 |
&rc, &herrno, NULL, &localcanon)); \
|
|
|
147e83 |
if (rc != ERANGE || herrno != NETDB_INTERNAL) \
|
|
|
147e83 |
break; \
|
|
|
147e83 |
- tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen); \
|
|
|
147e83 |
+ if (!malloc_tmpbuf && __libc_use_alloca (alloca_used + 2 * tmpbuflen)) \
|
|
|
147e83 |
+ tmpbuf = extend_alloca_account (tmpbuf, tmpbuflen, 2 * tmpbuflen, \
|
|
|
147e83 |
+ alloca_used); \
|
|
|
147e83 |
+ else \
|
|
|
147e83 |
+ { \
|
|
|
147e83 |
+ char *newp = realloc (malloc_tmpbuf ? tmpbuf : NULL, \
|
|
|
147e83 |
+ 2 * tmpbuflen); \
|
|
|
147e83 |
+ if (newp == NULL) \
|
|
|
147e83 |
+ { \
|
|
|
147e83 |
+ result = -EAI_MEMORY; \
|
|
|
147e83 |
+ goto free_and_return; \
|
|
|
147e83 |
+ } \
|
|
|
147e83 |
+ tmpbuf = newp; \
|
|
|
147e83 |
+ malloc_tmpbuf = true; \
|
|
|
147e83 |
+ tmpbuflen = 2 * tmpbuflen; \
|
|
|
147e83 |
+ } \
|
|
|
147e83 |
} \
|
|
|
147e83 |
if (status == NSS_STATUS_SUCCESS && rc == 0) \
|
|
|
147e83 |
h = &th; \
|
|
|
147e83 |
@@ -209,7 +224,8 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
|
|
|
147e83 |
{ \
|
|
|
147e83 |
__set_h_errno (herrno); \
|
|
|
147e83 |
_res.options |= old_res_options & RES_USE_INET6; \
|
|
|
147e83 |
- return -EAI_SYSTEM; \
|
|
|
147e83 |
+ result = -EAI_SYSTEM; \
|
|
|
147e83 |
+ goto free_and_return; \
|
|
|
147e83 |
} \
|
|
|
147e83 |
if (herrno == TRY_AGAIN) \
|
|
|
147e83 |
no_data = EAI_AGAIN; \
|