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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Fix fopen (non-existing-file, "re") errno


errno was set to EBADF with a call to fopen (non-existing-file, "re") instead 
of ENOENT. The problem was a missing check. Fixed with the appended patch,

Andreas

2011-08-19  Andreas Jaeger  <aj@suse.de>

	[BZ #13114]
	* libio/fileops.c (_IO_new_file_fopen): Fix handling of
	non-existant file when using closeexec mode.

-- 
 Andreas Jaeger, Program Manager openSUSE
  aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
   SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
    GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
     GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126
diff --git a/libio/fileops.c b/libio/fileops.c
index 30de460..6d9b52d 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -346,7 +346,8 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
 			  is32not64);
 
 #ifndef __ASSUME_O_CLOEXEC
-  if ((fp->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 && __have_o_cloexec <= 0)
+  if ((result != NULL)
+      && (fp->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 && __have_o_cloexec <= 0)
     {
       int fd = _IO_fileno (fp);
       if (__have_o_cloexec == 0)

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