This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]