This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.13-213-g7ea72f9
- From: drepper at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 21 May 2011 16:12:29 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.13-213-g7ea72f9
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 7ea72f99966a65a56aedba817ee2413ff9b1f23c (commit)
via 7e4afad5bcf49e03c3b987399c6a8f66a9018660 (commit)
from 8e211fecca7bddfb03a3aed54a47c243afddc150 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7ea72f99966a65a56aedba817ee2413ff9b1f23c
commit 7ea72f99966a65a56aedba817ee2413ff9b1f23c
Author: Ulrich Drepper <drepper@gmail.com>
Date: Sat May 21 12:11:36 2011 -0400
Always fill output buffer in XPG strerror function
diff --git a/ChangeLog b/ChangeLog
index fc2b7a8..bc73ba3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
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
numbers.
diff --git a/NEWS b/NEWS
index a99c74a..90ccee7 100644
--- a/NEWS
+++ b/NEWS
@@ -16,8 +16,8 @@ Version 2.14
12454, 12460, 12469, 12489, 12509, 12510, 12511, 12518, 12527, 12541,
12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611, 12625, 12626,
12631, 12650, 12653, 12655, 12660, 12681, 12685, 12711, 12713, 12714,
- 12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775, 12777, 12788,
- 12792
+ 12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775, 12777, 12782,
+ 12788, 12792
* The RPC implementation in libc is obsoleted. Old programs keep working
but new programs cannot be linked with the routines in libc anymore.
diff --git a/string/xpg-strerror.c b/string/xpg-strerror.c
index 8d89812..00256c3 100644
--- a/string/xpg-strerror.c
+++ b/string/xpg-strerror.c
@@ -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.
This file is part of the GNU C Library.
@@ -17,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <assert.h>
#include <errno.h>
#include <libintl.h>
#include <stdio.h>
@@ -37,16 +38,16 @@
int
__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
|| _sys_errlist_internal[errnum] == NULL)
return EINVAL;
- const char *estr = (const char *) _(_sys_errlist_internal[errnum]);
- size_t estrlen = strlen (estr) + 1;
-
- if (buflen < estrlen)
- return ERANGE;
+ assert (estr != buf);
+/* Terminate the string in any case. */
+ *((char *) __mempcpy (buf, estr, MIN (buflen - 1, estrlen))) = '\0';
- memcpy (buf, estr, estrlen);
- return 0;
+ return buflen <= estrlen ? ERANGE : 0;
}
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7e4afad5bcf49e03c3b987399c6a8f66a9018660
commit 7e4afad5bcf49e03c3b987399c6a8f66a9018660
Author: Ulrich Drepper <drepper@gmail.com>
Date: Sat May 21 12:09:23 2011 -0400
Nicer output for negative error numbers in strerror_r
diff --git a/ChangeLog b/ChangeLog
index a1dca5d..fc2b7a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-05-21 Ulrich Drepper <drepper@gmail.com>
+ * string/_strerror.c (__strerror_r): Print negative errors as signed
+ numbers.
+
[BZ #12777]
* iconvdata/cp1258.c (comp_table_data): Remove entry 0x00A5 0xEC.
(decomp_table): Change U0385 entry to emit 0xA5 0xEC.
diff --git a/string/_strerror.c b/string/_strerror.c
index cb5d9e3..ad9b148 100644
--- a/string/_strerror.c
+++ b/string/_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,93,95,96,97,98,2000,2002,2006
+/* Copyright (C) 1991,93,95,96,97,98,2000,2002,2006,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -18,7 +18,9 @@
02111-1307 USA. */
#include <libintl.h>
+#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <stdio-common/_itoa.h>
@@ -43,15 +45,21 @@ __strerror_r (int errnum, char *buf, size_t buflen)
`int' of 8 bytes we never need more than 20 digits. */
char numbuf[21];
const char *unk = _("Unknown error ");
- const size_t unklen = strlen (unk);
+ size_t unklen = strlen (unk);
char *p, *q;
+ bool negative = errnum < 0;
numbuf[20] = '\0';
- p = _itoa_word (errnum, &numbuf[20], 10, 0);
+ p = _itoa_word (abs (errnum), &numbuf[20], 10, 0);
/* Now construct the result while taking care for the destination
buffer size. */
q = __mempcpy (buf, unk, MIN (unklen, buflen));
+ if (negative && unklen < buflen)
+ {
+ *q++ = '-';
+ ++unklen;
+ }
if (unklen < buflen)
memcpy (q, p, MIN ((size_t) (&numbuf[21] - p), buflen - unklen));
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++++
NEWS | 4 ++--
string/_strerror.c | 14 +++++++++++---
string/xpg-strerror.c | 17 +++++++++--------
4 files changed, 29 insertions(+), 13 deletions(-)
hooks/post-receive
--
GNU C Library master sources