bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] bogus report-wait.c's describe_number's stpcpy


From: Samuel Thibault
Subject: [PATCH] bogus report-wait.c's describe_number's stpcpy
Date: Tue, 9 Dec 2008 03:09:55 +0100
User-agent: Mutt/1.5.12-2006-07-14

Hello,

While debugging odd buildd segfaults, I stumbled across 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.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]