Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix fopen (non-existing-file, "re") errno
  • Loading branch information
Andreas Jaeger authored and Ulrich Drepper committed Aug 20, 2011
1 parent fd70865 commit a101b02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
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 close-on-exec mode.

2011-08-20 Ulrich Drepper <drepper@gmail.com>

* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve): Fix CFI for
Expand Down
24 changes: 11 additions & 13 deletions libio/fileops.c
Expand Up @@ -345,23 +345,22 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
result = _IO_file_open (fp, filename, omode|oflags, oprot, read_write,
is32not64);

#ifndef __ASSUME_O_CLOEXEC
if ((fp->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 && __have_o_cloexec <= 0)
if (result != NULL)
{
int fd = _IO_fileno (fp);
if (__have_o_cloexec == 0)
#ifndef __ASSUME_O_CLOEXEC
if ((fp->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 && __have_o_cloexec <= 0)
{
int flags = __fcntl (fd, F_GETFD);
__have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
int fd = _IO_fileno (fp);
if (__have_o_cloexec == 0)
{
int flags = __fcntl (fd, F_GETFD);
__have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
}
if (__have_o_cloexec < 0)
__fcntl (fd, F_SETFD, FD_CLOEXEC);
}
if (__have_o_cloexec < 0)
__fcntl (fd, F_SETFD, FD_CLOEXEC);
}
#endif

#ifdef _LIBC
if (result != NULL)
{
/* Test whether the mode string specifies the conversion. */
cs = strstr (last_recognized + 1, ",ccs=");
if (cs != NULL)
Expand Down Expand Up @@ -432,7 +431,6 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
result->_mode = 1;
}
}
#endif /* GNU libc */

return result;
}
Expand Down

0 comments on commit a101b02

Please sign in to comment.