[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch]df and electric fence don't mix
From: |
Arjan van de Ven |
Subject: |
[patch]df and electric fence don't mix |
Date: |
Sat, 9 Dec 2000 14:58:37 +0100 |
User-agent: |
Mutt/1.2.5i |
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]))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [patch]df and electric fence don't mix,
Arjan van de Ven <=