bug-coreutils
[Top][All Lists]
Advanced

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

a memory bug in stat.c


From: Guochun Shi
Subject: a memory bug in stat.c
Date: Fri, 11 Mar 2005 16:57:41 -0600

hi,  list

I ran "stat -c %s <filename>" and get segmentation fault. I found there is a 
bug, here is a patch to fix it.
 

diff -u stat.c.old stat.c
--- stat.c.old  2003-03-22 16:32:02.000000000 -0600
+++ stat.c      2005-03-11 16:51:37.000000000 -0600
@@ -554,7 +554,7 @@
   /* create a working copy of the format string */
   char *format = xstrdup (masterformat);
 
-  char *dest = xmalloc (strlen (format) + 1);
+  char *dest = xmalloc (strlen (format) + 3);
 
 
   b = format;



The seg fault place is in stat.c:501 where PRuMAX is '"llu", so the total space 
required is 1 ('%')+ 3 + 1 ('\0')
however, strlen(format) + 1  in stat.c:557 is 3 since format is "%s"

please cc to my email account since I am not subscribing the mailing list.

Thanks
-Guochun






reply via email to

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