This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH roland/opendir-extra-stat] BZ#18921: Fix opendir inverted o_directory_works test.


This fix is trivial (and I'll put it on 2.22 as well when I commit).
I'm not committing immediately mostly because I have a vague hope that
someone will suggest a way of writing a test.

The failure mode is not user-visible in the usual sense, as the function
still behaves correctly.  There is a performance regression, but it is
probably very hard to measure the relevant things.  The bug was actually
caught by a test in the coreutils suite that uses strace to count the stat
syscalls made by ls invocations in particular circumstances.

Can anybody think of a way that a regression test for this could be written
that fits into the way we do things in libc?


Thanks,
Roland


2015-09-03  Roland McGrath  <roland@hack.frob.com>

	[BZ #18921]
	* sysdeps/posix/opendir.c (need_isdir_precheck) [O_DIRECTORY]:
	Fix inverted sense of test of 'o_directory_works' value.
	Reported by Pádraig Brady <P@draigBrady.com>, diagnosed by
	Bernhard Voelker <mail@bernhard-voelker.de>.

diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index 6509f5c..9edf056 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -105,7 +105,7 @@ need_isdir_precheck (void)
     tryopen_o_directory ();
 
   /* We can skip the expensive `stat' call if O_DIRECTORY works.  */
-  return o_directory_works > 0;
+  return o_directory_works < 0;
 #endif
   return true;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]