Contents of /trunk/glibc/patches/glibc-2.17-getaddrinfo-stack-overflow.patch
Parent Directory | Revision Log
Revision 2233 -
(show annotations)
(download)
Thu Jul 11 17:04:32 2013 UTC (11 years, 2 months ago) by niro
File size: 1436 byte(s)
Thu Jul 11 17:04:32 2013 UTC (11 years, 2 months ago) by niro
File size: 1436 byte(s)
-more patches
1 | diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c |
2 | index d95c2d1..2309281 100644 |
3 | --- a/sysdeps/posix/getaddrinfo.c |
4 | +++ b/sysdeps/posix/getaddrinfo.c |
5 | @@ -2489,11 +2489,27 @@ getaddrinfo (const char *name, const char *service, |
6 | __typeof (once) old_once = once; |
7 | __libc_once (once, gaiconf_init); |
8 | /* Sort results according to RFC 3484. */ |
9 | - struct sort_result results[nresults]; |
10 | - size_t order[nresults]; |
11 | + struct sort_result *results; |
12 | + size_t *order; |
13 | struct addrinfo *q; |
14 | struct addrinfo *last = NULL; |
15 | char *canonname = NULL; |
16 | + bool malloc_results; |
17 | + |
18 | + malloc_results |
19 | + = !__libc_use_alloca (nresults * (sizeof (*results) + sizeof (size_t))); |
20 | + if (malloc_results) |
21 | + { |
22 | + results = malloc (nresults * (sizeof (*results) + sizeof (size_t))); |
23 | + if (results == NULL) |
24 | + { |
25 | + __free_in6ai (in6ai); |
26 | + return EAI_MEMORY; |
27 | + } |
28 | + } |
29 | + else |
30 | + results = alloca (nresults * (sizeof (*results) + sizeof (size_t))); |
31 | + order = (size_t *) (results + nresults); |
32 | |
33 | /* Now we definitely need the interface information. */ |
34 | if (! check_pf_called) |
35 | @@ -2664,6 +2680,9 @@ getaddrinfo (const char *name, const char *service, |
36 | |
37 | /* Fill in the canonical name into the new first entry. */ |
38 | p->ai_canonname = canonname; |
39 | + |
40 | + if (malloc_results) |
41 | + free (results); |
42 | } |
43 | |
44 | __free_in6ai (in6ai); |
45 | -- |
46 | 1.7.1 |
47 |