[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep 2.4.2 bug (and patch)
From: |
David Clissold |
Subject: |
grep 2.4.2 bug (and patch) |
Date: |
Wed, 11 Jul 2001 17:16:49 -0500 |
Hi --
I found a small bug in the GNU grep 2.4.2, which may have gone unnoticed
because it only causes a failure if building on a system with large
files enabled (e.g. an "off_t" is a "long long" rather than a "long").
savedir() takes on off_t argument, but in grepdir() the parameter
is cast to an (unsigned). Well, if an off_t is larger than an int,
the value gets truncated. This would not normally have an effect on a
little-endian platform (unless the file is >2GB), but on a big-endian
system it will always fail. The external effect is that
"grep -r foo dir_name" fails with ENOMEM (from malloc() within savedir()).
Looking at the code, I see that the cast is not necessary to begin with.
Hence, the fix is simply to remove it, as in the patch below.
----
David Clissold
address@hidden
===========================================================================
*** grep-2.4.2/src/grep.c Fri Jul 6 18:10:14 2001
--- grep-2.4.2/src/grep.c Fri Jul 6 18:10:37 2001
***************
*** 889,895 ****
return 1;
}
! name_space = savedir (dir, (unsigned) stats->stat.st_size);
if (! name_space)
{
--- 889,895 ----
return 1;
}
! name_space = savedir (dir, stats->stat.st_size);
if (! name_space)
{
- grep 2.4.2 bug (and patch),
David Clissold <=