This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH,HURD] bogus report-wait.c's describe_number's stpcpy
- From: Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- To: roland at gnu dot org
- Cc: libc-alpha at sources dot redhat dot com
- Date: Wed, 7 Jan 2009 02:43:38 +0100
- Subject: [PATCH,HURD] bogus report-wait.c's describe_number's stpcpy
- References: <20081209020955.GO5379@const.famille.thibault.fr>
Hello,
There is some odd code in report-wait.c:
static char *
describe_number (string_t description, const char *flavor, long int i)
{
unsigned long int j;
char *p = flavor ? description : __stpcpy (description, flavor);
If flavor is NULL, that leads to __stpcpy(description, NULL), which
segfaults... I guess the intent was rather
static char *
describe_number (string_t description, const char *flavor, long int i)
{
unsigned long int j;
char *p = !flavor ? description : __stpcpy (description, flavor);
(note that report_wait is not so much used, it could very well be that
this bug never got noticed). If so, below is a patch.
Samuel
2008-12-09 Samuel Thibault <samuel.thibault@ens-lyon.org>
* hurd/report-wait.c (describe_number): Use __stpcpy to prepend
flavor to description only when flavor is not NULL.
Index: hurd/report-wait.c
===================================================================
RCS file: /cvs/glibc/libc/hurd/report-wait.c,v
retrieving revision 1.15
diff -u -p -r1.15 report-wait.c
--- hurd/report-wait.c 29 Dec 2005 10:38:12 -0000 1.15
+++ hurd/report-wait.c 9 Dec 2008 02:05:55 -0000
@@ -30,7 +30,7 @@ static char *
describe_number (string_t description, const char *flavor, long int i)
{
unsigned long int j;
- char *p = flavor ? description : __stpcpy (description, flavor);
+ char *p = !flavor ? description : __stpcpy (description, flavor);
char *end;
/* Handle sign. */