Hi,

In fileutils 4.0.32 (from debian woody), it is not possible to use the
Electric Fence bound-checker with the "df" program, when run without
arguments. This is caused by df mallocing 0 bytes of memory, which makes
electric fence barf. Now is mallocing 0 bytes not exactly defined behavior
(from the relevant man page:
|NOTE
|       xmalloc  and  xrealloc treat a request to allocate a block
|       of 0 bytes as an error.  xrealloc  will  allow  its  first
|       argument to be NULL.
)
and it happens to work because the result of the respective xmalloc is never
used (that is, when is 0, if it is nonzero, there is no problem).

The patch below fixes this. (If it is needed for me to sign over copyright
or so, consider that done)

Greetings,
   Arjan van de Ven

--- src/df.c.org        Sat Dec  9 14:42:54 2000
+++ src/df.c    Sat Dec  9 14:43:10 2000
@@ -891,8 +891,11 @@
 
     /* stat all the given entries to make sure they get automounted,
        if necessary, before reading the filesystem table.  */
-    stats = (struct stat *)
-      xmalloc ((argc - optind) * sizeof (struct stat));
+    if (argc!=optind)
+           stats = (struct stat *)
+               xmalloc ((argc - optind) * sizeof (struct stat));
+       else
+           stats = NULL;
     for (i = optind; i < argc; ++i)
       {
        if (stat (argv[i], &stats[i - optind]))

_______________________________________________
Bug-fileutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-fileutils

Reply via email to