mirror of
https://sourceware.org/git/glibc.git
synced 2025-06-13 19:21:36 +03:00
Always fill output buffer in XPG strerror function
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
2011-05-21 Ulrich Drepper <drepper@gmail.com>
|
2011-05-21 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
[BZ #12782]
|
||||||
|
* string/xpg-strerror.c (__xpg_strerror_r): Fill buffer even if error
|
||||||
|
is returned.
|
||||||
|
|
||||||
* string/_strerror.c (__strerror_r): Print negative errors as signed
|
* string/_strerror.c (__strerror_r): Print negative errors as signed
|
||||||
numbers.
|
numbers.
|
||||||
|
|
||||||
|
4
NEWS
4
NEWS
@ -16,8 +16,8 @@ Version 2.14
|
|||||||
12454, 12460, 12469, 12489, 12509, 12510, 12511, 12518, 12527, 12541,
|
12454, 12460, 12469, 12489, 12509, 12510, 12511, 12518, 12527, 12541,
|
||||||
12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611, 12625, 12626,
|
12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611, 12625, 12626,
|
||||||
12631, 12650, 12653, 12655, 12660, 12681, 12685, 12711, 12713, 12714,
|
12631, 12650, 12653, 12655, 12660, 12681, 12685, 12711, 12713, 12714,
|
||||||
12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775, 12777, 12788,
|
12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775, 12777, 12782,
|
||||||
12792
|
12788, 12792
|
||||||
|
|
||||||
* The RPC implementation in libc is obsoleted. Old programs keep working
|
* The RPC implementation in libc is obsoleted. Old programs keep working
|
||||||
but new programs cannot be linked with the routines in libc anymore.
|
but new programs cannot be linked with the routines in libc anymore.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2010
|
/* Copyright (C) 1991, 1993, 1995-1998, 2000, 2002, 2004, 2010, 2011
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@ -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 <errno.h>
|
#include <errno.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -37,16 +38,16 @@
|
|||||||
int
|
int
|
||||||
__xpg_strerror_r (int errnum, char *buf, size_t buflen)
|
__xpg_strerror_r (int errnum, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
|
const char *estr = __strerror_r (errnum, buf, buflen);
|
||||||
|
size_t estrlen = strlen (estr);
|
||||||
|
|
||||||
if (errnum < 0 || errnum >= _sys_nerr_internal
|
if (errnum < 0 || errnum >= _sys_nerr_internal
|
||||||
|| _sys_errlist_internal[errnum] == NULL)
|
|| _sys_errlist_internal[errnum] == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
const char *estr = (const char *) _(_sys_errlist_internal[errnum]);
|
assert (estr != buf);
|
||||||
size_t estrlen = strlen (estr) + 1;
|
/* Terminate the string in any case. */
|
||||||
|
*((char *) __mempcpy (buf, estr, MIN (buflen - 1, estrlen))) = '\0';
|
||||||
|
|
||||||
if (buflen < estrlen)
|
return buflen <= estrlen ? ERANGE : 0;
|
||||||
return ERANGE;
|
|
||||||
|
|
||||||
memcpy (buf, estr, estrlen);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user