glibc/getaddrinfo-overflow.patch
Andreas Schwab 8715963849 Accepting request 175892 from home:Andreas_Schwab:Factory
- big5-hkscs-update.patch.bz2: Update BIG5-HKSCS charmap to HKSCS-2008
- digits-dots.patch: Fix parsing of numeric hosts in gethostbyname_r
- nss-database.patch: Properly cache the result from looking up the nss
  database config
- strptime-W-week.patch: Properly handle %W in strptime
- printf-overrun.patch: Revert problematic fixes for [BZ #11741]
- glibc-aarch64-lib64.patch: Replace with upstream version
- arm-ld-so-cache.patch: ARM: Support loading unmarked objects from cache
- rtlddir.patch: Add support for rtld directory different from slib
  directory
- regexp-overrun.patch: Fix buffer overrun in regexp matcher
  (CVE-2013-0242, bnc#801246)
- getaddrinfo-overflow.patch: Fix stack overflow in getaddrinfo with many
  results (CVE-2013-1914, bnc#813121)

- big5-hkscs-update.patch.bz2: Update BIG5-HKSCS charmap to HKSCS-2008
- digits-dots.patch: Fix parsing of numeric hosts in gethostbyname_r
- nss-database.patch: Properly cache the result from looking up the nss
  database config
- strptime-W-week.patch: Properly handle %W in strptime
- printf-overrun.patch: Revert problematic fixes for [BZ #11741]
- glibc-aarch64-lib64.patch: Replace with upstream version
- arm-ld-so-cache.patch: ARM: Support loading unmarked objects from cache
- rtlddir.patch: Add support for rtld directory different from slib
  directory
- regexp-overrun.patch: Fix buffer overrun in regexp matcher
  (CVE-2013-0242, bnc#801246)
- getaddrinfo-overflow.patch: Fix stack overflow in getaddrinfo with many
  results (CVE-2013-1914, bnc#813121)

OBS-URL: https://build.opensuse.org/request/show/175892
OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=284
2013-05-16 15:57:30 +00:00

63 lines
1.9 KiB
Diff

From 1cef1b19089528db11f221e938f60b9b048945d7 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Thu, 21 Mar 2013 15:50:27 +0100
Subject: [PATCH] Fix stack overflow in getaddrinfo with many results
[BZ #15330]
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Allocate results and
order arrays from heap if bigger than alloca cutoff.
---
ChangeLog | 6 ++++++
NEWS | 5 ++++-
sysdeps/posix/getaddrinfo.c | 23 +++++++++++++++++++++--
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index d95c2d1..2309281 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2489,11 +2489,27 @@ getaddrinfo (const char *name, const char *service,
__typeof (once) old_once = once;
__libc_once (once, gaiconf_init);
/* Sort results according to RFC 3484. */
- struct sort_result results[nresults];
- size_t order[nresults];
+ struct sort_result *results;
+ size_t *order;
struct addrinfo *q;
struct addrinfo *last = NULL;
char *canonname = NULL;
+ bool malloc_results;
+
+ malloc_results
+ = !__libc_use_alloca (nresults * (sizeof (*results) + sizeof (size_t)));
+ if (malloc_results)
+ {
+ results = malloc (nresults * (sizeof (*results) + sizeof (size_t)));
+ if (results == NULL)
+ {
+ __free_in6ai (in6ai);
+ return EAI_MEMORY;
+ }
+ }
+ else
+ results = alloca (nresults * (sizeof (*results) + sizeof (size_t)));
+ order = (size_t *) (results + nresults);
/* Now we definitely need the interface information. */
if (! check_pf_called)
@@ -2664,6 +2680,9 @@ getaddrinfo (const char *name, const char *service,
/* Fill in the canonical name into the new first entry. */
p->ai_canonname = canonname;
+
+ if (malloc_results)
+ free (results);
}
__free_in6ai (in6ai);
--
1.8.2.3