mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
* sysdeps/unix/sysv/linux/ifreq.c (__ifreq): Fix memory handling. * sysdeps/generic/ifreq.c (__ifreq): Fix memory handling. * resolv/res_hconf.c (_res_hconf_reorder_addrs): Make clear that realloc cannot fail. * nss/nss_files/files-netgrp.c (EXPAND): Free buffer which cannot be expanded. * nis/nis_table.c: Clean up memory handling. * nis/nis_subr.c (nis_getnames): Clean up memory handling. * nis/nis_removemember.c (nis_removemember): Add comment explaining use of realloc.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@ -1,5 +1,19 @@
|
|||||||
2004-05-06 Ulrich Drepper <drepper@redhat.com>
|
2004-05-06 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/ifreq.c (__ifreq): Fix memory handling.
|
||||||
|
* sysdeps/generic/ifreq.c (__ifreq): Fix memory handling.
|
||||||
|
|
||||||
|
* resolv/res_hconf.c (_res_hconf_reorder_addrs): Make clear that
|
||||||
|
realloc cannot fail.
|
||||||
|
|
||||||
|
* nss/nss_files/files-netgrp.c (EXPAND): Free buffer which cannot
|
||||||
|
be expanded.
|
||||||
|
|
||||||
|
* nis/nis_table.c: Clean up memory handling.
|
||||||
|
* nis/nis_subr.c (nis_getnames): Clean up memory handling.
|
||||||
|
* nis/nis_removemember.c (nis_removemember): Add comment
|
||||||
|
explaining use of realloc.
|
||||||
|
|
||||||
* math/tgmath.h (fabs): Use __TGMATH_UNARY_REAL_IMAG_RET_REAL.
|
* math/tgmath.h (fabs): Use __TGMATH_UNARY_REAL_IMAG_RET_REAL.
|
||||||
(carg): Likewise.
|
(carg): Likewise.
|
||||||
Patch by Lev S Bishop <lev.bishop@yale.edu>.
|
Patch by Lev S Bishop <lev.bishop@yale.edu>.
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2004-05-06 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* stringprep.c (stringprep): Free memory if allocation failed.
|
||||||
|
* idna.c: Fix memory handling in several places.
|
||||||
|
|
||||||
2004-04-22 Simon Josefsson <jas@extundo.com>
|
2004-04-22 Simon Josefsson <jas@extundo.com>
|
||||||
|
|
||||||
* stringprep.h: Update to latest libidn version.
|
* stringprep.h: Update to latest libidn version.
|
||||||
|
@ -116,9 +116,13 @@ idna_to_ascii_4i (const uint32_t * in, size_t inlen, char *out, int flags)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
len = 2 * len + 10; /* XXX better guess? */
|
len = 2 * len + 10; /* XXX better guess? */
|
||||||
p = realloc (p, len);
|
char *newp = realloc (p, len);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return IDNA_MALLOC_ERROR;
|
{
|
||||||
|
free (p);
|
||||||
|
return IDNA_MALLOC_ERROR;
|
||||||
|
}
|
||||||
|
p = newp;
|
||||||
|
|
||||||
if (flags & IDNA_ALLOW_UNASSIGNED)
|
if (flags & IDNA_ALLOW_UNASSIGNED)
|
||||||
rc = stringprep_nameprep (p, len);
|
rc = stringprep_nameprep (p, len);
|
||||||
@ -288,9 +292,13 @@ idna_to_unicode_internal (char *utf8in,
|
|||||||
*/
|
*/
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
utf8in = realloc (utf8in, utf8len + addlen);
|
char *newp = realloc (utf8in, utf8len + addlen);
|
||||||
if (!utf8in)
|
if (newp == NULL)
|
||||||
return IDNA_MALLOC_ERROR;
|
{
|
||||||
|
free (utf8in);
|
||||||
|
return IDNA_MALLOC_ERROR;
|
||||||
|
}
|
||||||
|
utf8in = newp;
|
||||||
if (flags & IDNA_ALLOW_UNASSIGNED)
|
if (flags & IDNA_ALLOW_UNASSIGNED)
|
||||||
rc = stringprep_nameprep (utf8in, utf8len + addlen);
|
rc = stringprep_nameprep (utf8in, utf8len + addlen);
|
||||||
else
|
else
|
||||||
@ -300,7 +308,10 @@ idna_to_unicode_internal (char *utf8in,
|
|||||||
while (rc == STRINGPREP_TOO_SMALL_BUFFER);
|
while (rc == STRINGPREP_TOO_SMALL_BUFFER);
|
||||||
|
|
||||||
if (rc != STRINGPREP_OK)
|
if (rc != STRINGPREP_OK)
|
||||||
return IDNA_STRINGPREP_ERROR;
|
{
|
||||||
|
free (utf8in);
|
||||||
|
return IDNA_STRINGPREP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* 3. Verify that the sequence begins with the ACE prefix, and save a
|
/* 3. Verify that the sequence begins with the ACE prefix, and save a
|
||||||
* copy of the sequence.
|
* copy of the sequence.
|
||||||
@ -308,7 +319,10 @@ idna_to_unicode_internal (char *utf8in,
|
|||||||
|
|
||||||
step3:
|
step3:
|
||||||
if (memcmp (IDNA_ACE_PREFIX, utf8in, strlen (IDNA_ACE_PREFIX)) != 0)
|
if (memcmp (IDNA_ACE_PREFIX, utf8in, strlen (IDNA_ACE_PREFIX)) != 0)
|
||||||
return IDNA_NO_ACE_PREFIX;
|
{
|
||||||
|
free (utf8in);
|
||||||
|
return IDNA_NO_ACE_PREFIX;
|
||||||
|
}
|
||||||
|
|
||||||
/* 4. Remove the ACE prefix.
|
/* 4. Remove the ACE prefix.
|
||||||
*/
|
*/
|
||||||
@ -325,7 +339,10 @@ step3:
|
|||||||
|
|
||||||
rc = punycode_decode (strlen (utf8in), utf8in, outlen, out, NULL);
|
rc = punycode_decode (strlen (utf8in), utf8in, outlen, out, NULL);
|
||||||
if (rc != PUNYCODE_SUCCESS)
|
if (rc != PUNYCODE_SUCCESS)
|
||||||
return IDNA_PUNYCODE_ERROR;
|
{
|
||||||
|
free (utf8in);
|
||||||
|
return IDNA_PUNYCODE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
out[*outlen] = 0; /* add zero */
|
out[*outlen] = 0; /* add zero */
|
||||||
|
|
||||||
@ -334,18 +351,25 @@ step3:
|
|||||||
|
|
||||||
rc = idna_to_ascii_4i (out, *outlen, tmpout, flags);
|
rc = idna_to_ascii_4i (out, *outlen, tmpout, flags);
|
||||||
if (rc != IDNA_SUCCESS)
|
if (rc != IDNA_SUCCESS)
|
||||||
return rc;
|
{
|
||||||
|
free (utf8in);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* 7. Verify that the result of step 6 matches the saved copy from
|
/* 7. Verify that the result of step 6 matches the saved copy from
|
||||||
* step 3, using a case-insensitive ASCII comparison.
|
* step 3, using a case-insensitive ASCII comparison.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (strcasecmp (utf8in, tmpout + strlen (IDNA_ACE_PREFIX)) != 0)
|
if (strcasecmp (utf8in, tmpout + strlen (IDNA_ACE_PREFIX)) != 0)
|
||||||
return IDNA_ROUNDTRIP_VERIFY_ERROR;
|
{
|
||||||
|
free (utf8in);
|
||||||
|
return IDNA_ROUNDTRIP_VERIFY_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* 8. Return the saved copy from step 5.
|
/* 8. Return the saved copy from step 5.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
free (utf8in);
|
||||||
return IDNA_SUCCESS;
|
return IDNA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +428,7 @@ idna_to_unicode_44i (const uint32_t * in, size_t inlen,
|
|||||||
*outlen = inlen;
|
*outlen = inlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
free (p);
|
/* p is freed in idna_to_unicode_internal. */
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -479,9 +503,13 @@ idna_to_ascii_4z (const uint32_t * input, char **output, int flags)
|
|||||||
|
|
||||||
if (out)
|
if (out)
|
||||||
{
|
{
|
||||||
out = realloc (out, strlen (out) + 1 + strlen (buf) + 1);
|
char *newp = realloc (out, strlen (out) + 1 + strlen (buf) + 1);
|
||||||
if (!out)
|
if (!newp)
|
||||||
return IDNA_MALLOC_ERROR;
|
{
|
||||||
|
free (out);
|
||||||
|
return IDNA_MALLOC_ERROR;
|
||||||
|
}
|
||||||
|
out = newp;
|
||||||
strcat (out, ".");
|
strcat (out, ".");
|
||||||
strcat (out, buf);
|
strcat (out, buf);
|
||||||
}
|
}
|
||||||
@ -605,9 +633,16 @@ idna_to_unicode_4z4z (const uint32_t * input, uint32_t ** output, int flags)
|
|||||||
|
|
||||||
if (out)
|
if (out)
|
||||||
{
|
{
|
||||||
out = realloc (out, sizeof (out[0]) * (outlen + 1 + buflen + 1));
|
uint32_t *newp = realloc (out,
|
||||||
if (!out)
|
sizeof (out[0])
|
||||||
return IDNA_MALLOC_ERROR;
|
* (outlen + 1 + buflen + 1));
|
||||||
|
if (!newp)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
free (out);
|
||||||
|
return IDNA_MALLOC_ERROR;
|
||||||
|
}
|
||||||
|
out = newp;
|
||||||
out[outlen++] = 0x002E; /* '.' (full stop) */
|
out[outlen++] = 0x002E; /* '.' (full stop) */
|
||||||
memcpy (out + outlen, buf, sizeof (buf[0]) * buflen);
|
memcpy (out + outlen, buf, sizeof (buf[0]) * buflen);
|
||||||
outlen += buflen;
|
outlen += buflen;
|
||||||
|
@ -370,9 +370,13 @@ stringprep (char *in,
|
|||||||
free (ucs4);
|
free (ucs4);
|
||||||
ucs4 = stringprep_utf8_to_ucs4 (in, -1, &ucs4len);
|
ucs4 = stringprep_utf8_to_ucs4 (in, -1, &ucs4len);
|
||||||
maxucs4len = ucs4len + adducs4len;
|
maxucs4len = ucs4len + adducs4len;
|
||||||
ucs4 = realloc (ucs4, maxucs4len * sizeof (uint32_t));
|
uint32_t *newp = realloc (ucs4, maxucs4len * sizeof (uint32_t));
|
||||||
if (!ucs4)
|
if (!newp)
|
||||||
return STRINGPREP_MALLOC_ERROR;
|
{
|
||||||
|
free (ucs4);
|
||||||
|
return STRINGPREP_MALLOC_ERROR;
|
||||||
|
}
|
||||||
|
ucs4 = newp;
|
||||||
|
|
||||||
rc = stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
|
rc = stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
|
||||||
adducs4len += 50;
|
adducs4len += 50;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
|
/* Copyright (c) 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
|
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
|
||||||
|
|
||||||
@ -17,6 +17,7 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <rpcsvc/nis.h>
|
#include <rpcsvc/nis.h>
|
||||||
|
|
||||||
@ -87,6 +88,10 @@ nis_removemember (const_nis_name member, const_nis_name group)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val);
|
free (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val);
|
||||||
|
assert (k <= NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len);
|
||||||
|
/* This realloc() call always decreases the size. This cannot
|
||||||
|
fail. We still have the test but do not recover memory
|
||||||
|
(i.e., we overwrite the input pointer). */
|
||||||
newmem = realloc (newmem, k * sizeof (char*));
|
newmem = realloc (newmem, k * sizeof (char*));
|
||||||
if (newmem == NULL)
|
if (newmem == NULL)
|
||||||
return NIS_NOMEMORY;
|
return NIS_NOMEMORY;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 1997, 1999, 2000 Free Software Foundation, Inc.
|
/* Copyright (c) 1997, 1999, 2000, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
|
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
|
||||||
|
|
||||||
@ -117,8 +117,11 @@ nis_getnames (const_nis_name name)
|
|||||||
{
|
{
|
||||||
nis_name *getnames = NULL;
|
nis_name *getnames = NULL;
|
||||||
char local_domain[NIS_MAXNAMELEN + 1];
|
char local_domain[NIS_MAXNAMELEN + 1];
|
||||||
char *path, *cp;
|
char *path;
|
||||||
int count, pos, have_point;
|
char *cp;
|
||||||
|
int count;
|
||||||
|
int pos = 0;
|
||||||
|
int have_point;
|
||||||
char *saveptr;
|
char *saveptr;
|
||||||
|
|
||||||
strncpy (local_domain, nis_local_directory (), NIS_MAXNAMELEN);
|
strncpy (local_domain, nis_local_directory (), NIS_MAXNAMELEN);
|
||||||
@ -133,7 +136,13 @@ nis_getnames (const_nis_name name)
|
|||||||
if (name[strlen (name) - 1] == '.')
|
if (name[strlen (name) - 1] == '.')
|
||||||
{
|
{
|
||||||
if ((getnames[0] = strdup (name)) == NULL)
|
if ((getnames[0] = strdup (name)) == NULL)
|
||||||
return NULL;
|
{
|
||||||
|
free_null:
|
||||||
|
while (pos-- > 0)
|
||||||
|
free (getnames[pos]);
|
||||||
|
free (getnames);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
getnames[1] = NULL;
|
getnames[1] = NULL;
|
||||||
|
|
||||||
@ -149,8 +158,6 @@ nis_getnames (const_nis_name name)
|
|||||||
|
|
||||||
have_point = (strchr (name, '.') != NULL);
|
have_point = (strchr (name, '.') != NULL);
|
||||||
|
|
||||||
pos = 0;
|
|
||||||
|
|
||||||
cp = __strtok_r (path, ":", &saveptr);
|
cp = __strtok_r (path, ":", &saveptr);
|
||||||
while (cp)
|
while (cp)
|
||||||
{
|
{
|
||||||
@ -164,14 +171,16 @@ nis_getnames (const_nis_name name)
|
|||||||
if (pos >= count)
|
if (pos >= count)
|
||||||
{
|
{
|
||||||
count += 5;
|
count += 5;
|
||||||
getnames = realloc (getnames, (count + 1) * sizeof (char *));
|
nis_name *newp = realloc (getnames,
|
||||||
if (__builtin_expect (getnames == NULL, 0))
|
(count + 1) * sizeof (char *));
|
||||||
return NULL;
|
if (__builtin_expect (newp == NULL, 0))
|
||||||
|
goto free_null;
|
||||||
|
getnames = newp;
|
||||||
}
|
}
|
||||||
tmp = malloc (strlen (cptr) + strlen (local_domain) +
|
tmp = malloc (strlen (cptr) + strlen (local_domain) +
|
||||||
strlen (name) + 2);
|
strlen (name) + 2);
|
||||||
if (__builtin_expect (tmp == NULL, 0))
|
if (__builtin_expect (tmp == NULL, 0))
|
||||||
return NULL;
|
goto free_null;
|
||||||
|
|
||||||
getnames[pos] = tmp;
|
getnames[pos] = tmp;
|
||||||
tmp = stpcpy (tmp, name);
|
tmp = stpcpy (tmp, name);
|
||||||
@ -201,7 +210,7 @@ nis_getnames (const_nis_name name)
|
|||||||
|
|
||||||
tmp = malloc (cplen + strlen (local_domain) + strlen (name) + 2);
|
tmp = malloc (cplen + strlen (local_domain) + strlen (name) + 2);
|
||||||
if (__builtin_expect (tmp == NULL, 0))
|
if (__builtin_expect (tmp == NULL, 0))
|
||||||
return NULL;
|
goto free_null;
|
||||||
|
|
||||||
p = __stpcpy (tmp, name);
|
p = __stpcpy (tmp, name);
|
||||||
*p++ = '.';
|
*p++ = '.';
|
||||||
@ -217,7 +226,7 @@ nis_getnames (const_nis_name name)
|
|||||||
|
|
||||||
tmp = malloc (cplen + strlen (name) + 2);
|
tmp = malloc (cplen + strlen (name) + 2);
|
||||||
if (__builtin_expect (tmp == NULL, 0))
|
if (__builtin_expect (tmp == NULL, 0))
|
||||||
return NULL;
|
goto free_null;
|
||||||
|
|
||||||
p = __stpcpy (tmp, name);
|
p = __stpcpy (tmp, name);
|
||||||
*p++ = '.';
|
*p++ = '.';
|
||||||
@ -227,9 +236,11 @@ nis_getnames (const_nis_name name)
|
|||||||
if (pos >= count)
|
if (pos >= count)
|
||||||
{
|
{
|
||||||
count += 5;
|
count += 5;
|
||||||
getnames = realloc (getnames, (count + 1) * sizeof (char *));
|
nis_name *newp = realloc (getnames,
|
||||||
if (__builtin_expect (getnames == NULL, 0))
|
(count + 1) * sizeof (char *));
|
||||||
return NULL;
|
if (__builtin_expect (newp == NULL, 0))
|
||||||
|
goto free_null;
|
||||||
|
getnames = newp;
|
||||||
}
|
}
|
||||||
getnames[pos] = tmp;
|
getnames[pos] = tmp;
|
||||||
++pos;
|
++pos;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
|
/* Copyright (c) 1997, 1998, 1999, 2003, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
|
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ __create_ib_request (const_nis_name name, unsigned int flags)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we have an entry of "[key=value,],bar". If, remove the "," */
|
/* Check if we have an entry of "[key=value,],bar". If, remove the "," */
|
||||||
if (ibreq->ibr_name[-1] == ',')
|
if (ibreq->ibr_name[-1] == ',')
|
||||||
ibreq->ibr_name[-1] = '\0';
|
ibreq->ibr_name[-1] = '\0';
|
||||||
else
|
else
|
||||||
@ -62,7 +62,17 @@ __create_ib_request (const_nis_name name, unsigned int flags)
|
|||||||
ibreq->ibr_name += 2;
|
ibreq->ibr_name += 2;
|
||||||
ibreq->ibr_name = strdup (ibreq->ibr_name);
|
ibreq->ibr_name = strdup (ibreq->ibr_name);
|
||||||
if (ibreq->ibr_name == NULL)
|
if (ibreq->ibr_name == NULL)
|
||||||
return NULL;
|
{
|
||||||
|
free_null:
|
||||||
|
while (search_len-- > 0)
|
||||||
|
{
|
||||||
|
free (search_val[search_len].zattr_ndx);
|
||||||
|
free (search_val[search_len].zattr_val.zattr_val_val);
|
||||||
|
}
|
||||||
|
free (search_val);
|
||||||
|
nis_free_request (ibreq);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
++cptr; /* Remove "[" */
|
++cptr; /* Remove "[" */
|
||||||
|
|
||||||
@ -86,16 +96,19 @@ __create_ib_request (const_nis_name name, unsigned int flags)
|
|||||||
size += 1;
|
size += 1;
|
||||||
search_val = realloc (search_val, size * sizeof (nis_attr));
|
search_val = realloc (search_val, size * sizeof (nis_attr));
|
||||||
if (search_val == NULL)
|
if (search_val == NULL)
|
||||||
return NULL;
|
goto free_null;
|
||||||
}
|
}
|
||||||
search_val[search_len].zattr_ndx = strdup (key);
|
search_val[search_len].zattr_ndx = strdup (key);
|
||||||
if ((search_val[search_len].zattr_ndx) == NULL)
|
if ((search_val[search_len].zattr_ndx) == NULL)
|
||||||
return NULL;
|
goto free_null;
|
||||||
|
|
||||||
search_val[search_len].zattr_val.zattr_val_len = strlen (val) + 1;
|
search_val[search_len].zattr_val.zattr_val_len = strlen (val) + 1;
|
||||||
search_val[search_len].zattr_val.zattr_val_val = strdup (val);
|
search_val[search_len].zattr_val.zattr_val_val = strdup (val);
|
||||||
if (search_val[search_len].zattr_val.zattr_val_val == NULL)
|
if (search_val[search_len].zattr_val.zattr_val_val == NULL)
|
||||||
return NULL;
|
{
|
||||||
|
free (search_val[search_len].zattr_ndx);
|
||||||
|
goto free_null;
|
||||||
|
}
|
||||||
|
|
||||||
++search_len;
|
++search_len;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Netgroup file parser in nss_files modules.
|
/* Netgroup file parser in nss_files modules.
|
||||||
Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1996, 1997, 2000, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||||
|
|
||||||
@ -34,12 +34,14 @@
|
|||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
size_t old_cursor = result->cursor - result->data; \
|
size_t old_cursor = result->cursor - result->data; \
|
||||||
|
void *old_data = result->data; \
|
||||||
\
|
\
|
||||||
result->data_size += 512 > 2 * needed ? 512 : 2 * needed; \
|
result->data_size += 512 > 2 * needed ? 512 : 2 * needed; \
|
||||||
result->data = realloc (result->data, result->data_size); \
|
result->data = realloc (result->data, result->data_size); \
|
||||||
\
|
\
|
||||||
if (result->data == NULL) \
|
if (result->data == NULL) \
|
||||||
{ \
|
{ \
|
||||||
|
free (old_data); \
|
||||||
status = NSS_STATUS_UNAVAIL; \
|
status = NSS_STATUS_UNAVAIL; \
|
||||||
goto the_end; \
|
goto the_end; \
|
||||||
} \
|
} \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1993, 1995-2001, 2002, 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 1993, 1995-2003, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by David Mosberger (davidm@azstarnet.com).
|
Contributed by David Mosberger (davidm@azstarnet.com).
|
||||||
|
|
||||||
@ -29,6 +29,7 @@
|
|||||||
a line)
|
a line)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
@ -577,6 +578,7 @@ _res_hconf_reorder_addrs (struct hostent *hp)
|
|||||||
}
|
}
|
||||||
/* Just keep enough memory to hold all the interfaces we want. */
|
/* Just keep enough memory to hold all the interfaces we want. */
|
||||||
ifaddrs = realloc (ifaddrs, num_ifs * sizeof (ifaddrs[0]));
|
ifaddrs = realloc (ifaddrs, num_ifs * sizeof (ifaddrs[0]));
|
||||||
|
assert (ifaddrs != NULL);
|
||||||
|
|
||||||
cleanup1:
|
cleanup1:
|
||||||
__if_freereq (ifr, num);
|
__if_freereq (ifr, num);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Andreas Jaeger <aj@suse.de>.
|
Contributed by Andreas Jaeger <aj@suse.de>.
|
||||||
|
|
||||||
@ -43,11 +43,10 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ifc.ifc_len = rq_len *= 2;
|
ifc.ifc_len = rq_len *= 2;
|
||||||
ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
|
void *newp = realloc (ifc.ifc_buf, ifc.ifc_len);
|
||||||
if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
|
if (newp == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
|
||||||
{
|
{
|
||||||
if (ifc.ifc_buf)
|
free (ifc.ifc_buf);
|
||||||
free (ifc.ifc_buf);
|
|
||||||
|
|
||||||
if (fd != sockfd)
|
if (fd != sockfd)
|
||||||
__close (fd);
|
__close (fd);
|
||||||
@ -55,6 +54,7 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
|
|||||||
*ifreqs = NULL;
|
*ifreqs = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ifc.ifc_buf = newp;
|
||||||
}
|
}
|
||||||
while (rq_len < sizeof (struct ifreq) + ifc.ifc_len);
|
while (rq_len < sizeof (struct ifreq) + ifc.ifc_len);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Andreas Jaeger <aj@suse.de>.
|
Contributed by Andreas Jaeger <aj@suse.de>.
|
||||||
|
|
||||||
@ -70,11 +70,10 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
ifc.ifc_len = rq_len;
|
ifc.ifc_len = rq_len;
|
||||||
ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
|
void *newp = realloc (ifc.ifc_buf, ifc.ifc_len);
|
||||||
if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
|
if (newp == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
|
||||||
{
|
{
|
||||||
if (ifc.ifc_buf)
|
free (ifc.ifc_buf);
|
||||||
free (ifc.ifc_buf);
|
|
||||||
|
|
||||||
if (fd != sockfd)
|
if (fd != sockfd)
|
||||||
__close (fd);
|
__close (fd);
|
||||||
@ -83,6 +82,7 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
|
|||||||
*ifreqs = NULL;
|
*ifreqs = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ifc.ifc_buf = newp;
|
||||||
|
|
||||||
if (!old_siocgifconf || ifc.ifc_len < rq_len)
|
if (!old_siocgifconf || ifc.ifc_len < rq_len)
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user