2007-03-12 Eric Blake <ebb9@byu.net>
* libc/stdio/fvwrite.c (__sfvwrite_r): Fix reentrancy. * libc/stdio/vasprintf.c (vasprintf, _vasprintf_r): Pass failed allocation to caller. * libc/stdio/asprintf.c (_asprintf_r, asprintf): Likewise. * libc/stdio/asiprintf.c (_asiprintf_r, asiprintf): Likewise. * libc/stdio/vasiprintf.c (vasiprintf, _vasiprintf_r): Likewise.
This commit is contained in:
parent
9c28809c0f
commit
99304ce6c4
@ -1,3 +1,12 @@
|
|||||||
|
2007-03-12 Eric Blake <ebb9@byu.net>
|
||||||
|
|
||||||
|
* libc/stdio/fvwrite.c (__sfvwrite_r): Fix reentrancy.
|
||||||
|
* libc/stdio/vasprintf.c (vasprintf, _vasprintf_r): Pass failed
|
||||||
|
allocation to caller.
|
||||||
|
* libc/stdio/asprintf.c (_asprintf_r, asprintf): Likewise.
|
||||||
|
* libc/stdio/asiprintf.c (_asiprintf_r, asiprintf): Likewise.
|
||||||
|
* libc/stdio/vasiprintf.c (vasiprintf, _vasiprintf_r): Likewise.
|
||||||
|
|
||||||
2007-02-23 Jeff Johnston <jjohnstn@redhat.com>
|
2007-02-23 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* libm/math/w_pow.c: Fix typo in documentation comment.
|
* libm/math/w_pow.c: Fix typo in documentation comment.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
@ -57,8 +57,11 @@ _asiprintf_r(ptr, strp, fmt, va_alist)
|
|||||||
#endif
|
#endif
|
||||||
ret = vfiprintf (&f, fmt, ap);
|
ret = vfiprintf (&f, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +95,11 @@ asiprintf(strp, fmt, va_alist)
|
|||||||
#endif
|
#endif
|
||||||
ret = vfiprintf (&f, fmt, ap);
|
ret = vfiprintf (&f, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
@ -57,8 +57,11 @@ _asprintf_r(ptr, strp, fmt, va_alist)
|
|||||||
#endif
|
#endif
|
||||||
ret = vfprintf (&f, fmt, ap);
|
ret = vfprintf (&f, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +95,11 @@ asprintf(strp, fmt, va_alist)
|
|||||||
#endif
|
#endif
|
||||||
ret = vfprintf (&f, fmt, ap);
|
ret = vfprintf (&f, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1990, 2006 The Regents of the University of California.
|
* Copyright (c) 1990, 2006, 2007 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
@ -129,7 +129,7 @@ _DEFUN(__sfvwrite_r, (ptr, fp, uio),
|
|||||||
{
|
{
|
||||||
if (len >= w && fp->_flags & __SMBF)
|
if (len >= w && fp->_flags & __SMBF)
|
||||||
{ /* must be asprintf family */
|
{ /* must be asprintf family */
|
||||||
unsigned char *ptr;
|
unsigned char *str;
|
||||||
int curpos = (fp->_p - fp->_bf._base);
|
int curpos = (fp->_p - fp->_bf._base);
|
||||||
/* Choose a geometric growth factor to avoid
|
/* Choose a geometric growth factor to avoid
|
||||||
quadratic realloc behavior, but use a rate less
|
quadratic realloc behavior, but use a rate less
|
||||||
@ -141,17 +141,16 @@ _DEFUN(__sfvwrite_r, (ptr, fp, uio),
|
|||||||
int newsize = fp->_bf._size * 3 / 2;
|
int newsize = fp->_bf._size * 3 / 2;
|
||||||
if (newsize < curpos + len + 1)
|
if (newsize < curpos + len + 1)
|
||||||
newsize = curpos + len + 1;
|
newsize = curpos + len + 1;
|
||||||
ptr = (unsigned char *)_realloc_r (_REENT,
|
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base,
|
||||||
fp->_bf._base,
|
newsize);
|
||||||
newsize);
|
if (!str)
|
||||||
if (!ptr)
|
|
||||||
{
|
{
|
||||||
/* Free buffer which is no longer used. */
|
/* Free buffer which is no longer used. */
|
||||||
_free_r (_REENT, fp->_bf._base);
|
_free_r (ptr, fp->_bf._base);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
fp->_bf._base = ptr;
|
fp->_bf._base = str;
|
||||||
fp->_p = ptr + curpos;
|
fp->_p = str + curpos;
|
||||||
fp->_bf._size = newsize;
|
fp->_bf._size = newsize;
|
||||||
w = len;
|
w = len;
|
||||||
fp->_w = newsize - curpos;
|
fp->_w = newsize - curpos;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
@ -46,8 +46,11 @@ _DEFUN(vasiprintf, (strp, fmt, ap),
|
|||||||
f._bf._size = f._w = 0;
|
f._bf._size = f._w = 0;
|
||||||
f._file = -1; /* No file. */
|
f._file = -1; /* No file. */
|
||||||
ret = _vfiprintf_r (_REENT, &f, fmt, ap);
|
ret = _vfiprintf_r (_REENT, &f, fmt, ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +71,10 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap),
|
|||||||
f._bf._size = f._w = 0;
|
f._bf._size = f._w = 0;
|
||||||
f._file = -1; /* No file. */
|
f._file = -1; /* No file. */
|
||||||
ret = _vfiprintf_r (ptr, &f, fmt, ap);
|
ret = _vfiprintf_r (ptr, &f, fmt, ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
@ -46,8 +46,11 @@ _DEFUN(vasprintf, (strp, fmt, ap),
|
|||||||
f._bf._size = f._w = 0;
|
f._bf._size = f._w = 0;
|
||||||
f._file = -1; /* No file. */
|
f._file = -1; /* No file. */
|
||||||
ret = _vfprintf_r (_REENT, &f, fmt, ap);
|
ret = _vfprintf_r (_REENT, &f, fmt, ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +71,10 @@ _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap),
|
|||||||
f._bf._size = f._w = 0;
|
f._bf._size = f._w = 0;
|
||||||
f._file = -1; /* No file. */
|
f._file = -1; /* No file. */
|
||||||
ret = _vfprintf_r (ptr, &f, fmt, ap);
|
ret = _vfprintf_r (ptr, &f, fmt, ap);
|
||||||
*f._p = 0;
|
if (ret >= 0)
|
||||||
*strp = f._bf._base;
|
{
|
||||||
|
*f._p = 0;
|
||||||
|
*strp = f._bf._base;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user