severity 537434 normal
tags 537434 = patch
thanks
(Note: the bug was incorrectly marked as "pending", probably due to a
typo in the bug number; the "pending" tag should have been applied to
a different bug.)
On 2010-02-12 13:45:55 +0100, Vincent Lefevre wrote:
> I've done some analysis with strace. The problem is that in zsoelim.c,
> man sometimes tries to open man1/zshxxx.1 instead of the .gz version.
> The reason is a bug in decompress_open() from lib/decompress.c (the
> function sometimes returns a non-null pointer value, though stat()
> failed). The code contains:
>
> if (stat (filename, &st) < 0 && !S_ISDIR (st.st_mode))
> return NULL;
>
> But if stat() fails, st may not have been filled in, so that the
> test !S_ISDIR (st.st_mode) makes no sense. Shouldn't this be:
>
> if (stat (filename, &st) < 0 || S_ISDIR (st.st_mode))
> return NULL;
>
> i.e. if the file doesn't exist or is a directory, one returns a
> null pointer?
I've attached a patch corresponding to this change. Seems to work.
--
Vincent Lefèvre <[email protected]> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
--- lib/decompress.c~ 2008-09-08 06:14:11.000000000 +0000
+++ lib/decompress.c 2010-02-12 13:01:50.000000000 +0000
@@ -77,7 +77,7 @@
char *ext;
struct compression *comp;
- if (stat (filename, &st) < 0 && !S_ISDIR (st.st_mode))
+ if (stat (filename, &st) < 0 || S_ISDIR (st.st_mode))
return NULL;
#ifdef HAVE_LIBZ