2
0
mirror of git://sourceware.org/git/glibc.git synced 2025-04-24 14:41:06 +08:00

Fix gethostbyname_r example. Fixes bug 2801.

This commit is contained in:
Ondřej Bílka 2013-10-25 19:16:08 +02:00
parent 10b0f26b19
commit 151659f637
3 changed files with 18 additions and 11 deletions

@ -1,3 +1,8 @@
2013-10-25 Ondřej Bílka <neleai@seznam.cz>
[BZ 2801]
* manual/socket.texi (Host Names): Fix gethostbyname_r example.
2013-10-25 Ondřej Bílka <neleai@seznam.cz>
[BZ #14876]

16
NEWS

@ -9,14 +9,14 @@ Version 2.19
* The following bugs are resolved with this release:
156, 431, 832, 10278, 13028, 13982, 13985, 14029, 14155, 14547, 14699,
14876, 14910, 15048, 15218, 15277, 15308, 15362, 15400, 15427, 15522,
15531, 15532, 15608, 15609, 15610, 15632, 15640, 15670, 15672, 15680,
15681, 15723, 15734, 15735, 15736, 15748, 15749, 15754, 15760, 15764,
15797, 15825, 15844, 15847, 15849, 15855, 15856, 15857, 15859, 15867,
15886, 15887, 15890, 15892, 15893, 15895, 15897, 15905, 15909, 15919,
15921, 15923, 15939, 15948, 15963, 15966, 15988, 16032, 16034, 16036,
16041, 16072, 16074.
156, 431, 832, 2801, 10278, 13028, 13982, 13985, 14029, 14155, 14547,
14699, 14876, 14910, 15048, 15218, 15277, 15308, 15362, 15400, 15427,
15522, 15531, 15532, 15608, 15609, 15610, 15632, 15640, 15670, 15672,
15680, 15681, 15723, 15734, 15735, 15736, 15748, 15749, 15754, 15760,
15764, 15797, 15825, 15844, 15847, 15849, 15855, 15856, 15857, 15859,
15867, 15886, 15887, 15890, 15892, 15893, 15895, 15897, 15905, 15909,
15919, 15921, 15923, 15939, 15948, 15963, 15966, 15988, 16032, 16034,
16036, 16041, 16072, 16074.
* CVE-2012-4412 The strcoll implementation caches indices and rules for
large collation sequences to optimize multiple passes. This cache

@ -1307,23 +1307,25 @@ Here's a small example:
struct hostent *
gethostname (char *host)
@{
struct hostent hostbuf, *hp;
struct hostent *hostbuf, *hp;
size_t hstbuflen;
char *tmphstbuf;
int res;
int herr;
hostbuf = malloc (sizeof (struct hostent));
hstbuflen = 1024;
/* Allocate buffer, remember to free it to avoid memory leakage. */
tmphstbuf = malloc (hstbuflen);
while ((res = gethostbyname_r (host, &hostbuf, tmphstbuf, hstbuflen,
while ((res = gethostbyname_r (host, hostbuf, tmphstbuf, hstbuflen,
&hp, &herr)) == ERANGE)
@{
/* Enlarge the buffer. */
hstbuflen *= 2;
tmphstbuf = realloc (tmphstbuf, hstbuflen);
@}
free (tmphstbuf);
/* Check for errors. */
if (res || hp == NULL)
return NULL;