public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12685] New: fopen doesn't last byte of valid modes
@ 2011-04-20  0:46 eblake at redhat dot com
  2011-04-20  0:47 ` [Bug libc/12685] fopen doesn't honor " eblake at redhat dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: eblake at redhat dot com @ 2011-04-20  0:46 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

           Summary: fopen doesn't last byte of valid modes
           Product: glibc
           Version: 2.13
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: eblake@redhat.com


$ cat foo.c
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>

int main (void)
{
  FILE *f = fopen ("/dev/null", "rb+cmxe");
  if (!f) exit (1);
  int fd = fileno (f);
  if (fd < 0) exit (2);
  int mode = fcntl (fd, F_GETFD);
  if (mode < 0) exit (3);
  return !(mode & FD_CLOEXEC);
}
$ ./foo; echo $?
1

Oops - an off-by-one error in fileops.c ended up ignoring 'e'.  The same goes
for any other valid byte that doesn't appear until mode[6].

diff --git i/libio/fileops.c w/libio/fileops.c
index 4698953..ee6ce13 100644
--- i/libio/fileops.c
+++ w/libio/fileops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997-2005, 2006, 2007, 2008, 2009
+/* Copyright (C) 1993, 1995, 1997-2005, 2006, 2007, 2008, 2009, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Per Bothner <bothner@cygnus.com>.
@@ -290,7 +290,7 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
 #ifdef _LIBC
   last_recognized = mode;
 #endif
-  for (i = 1; i < 6; ++i)
+  for (i = 1; i < 7; ++i)
     {
       switch (*++mode)
     {

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
@ 2011-04-20  0:47 ` eblake at redhat dot com
  2011-04-20  0:52 ` ppluzhnikov at google dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: eblake at redhat dot com @ 2011-04-20  0:47 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

Eric Blake <eblake at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|fopen doesn't last byte of  |fopen doesn't honor last
                   |valid modes                 |byte of valid modes

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
  2011-04-20  0:47 ` [Bug libc/12685] fopen doesn't honor " eblake at redhat dot com
@ 2011-04-20  0:52 ` ppluzhnikov at google dot com
  2011-04-23  3:42 ` drepper.fsp at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppluzhnikov at google dot com @ 2011-04-20  0:52 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

Paul Pluzhnikov <ppluzhnikov at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppluzhnikov at google dot
                   |                            |com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
  2011-04-20  0:47 ` [Bug libc/12685] fopen doesn't honor " eblake at redhat dot com
  2011-04-20  0:52 ` ppluzhnikov at google dot com
@ 2011-04-23  3:42 ` drepper.fsp at gmail dot com
  2012-04-22  1:59 ` mtk.manpages at gmail dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-04-23  3:42 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #1 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-04-23 03:41:46 UTC ---
The patch didn't apply.  I did it manually.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (2 preceding siblings ...)
  2011-04-23  3:42 ` drepper.fsp at gmail dot com
@ 2012-04-22  1:59 ` mtk.manpages at gmail dot com
  2012-04-22  2:02 ` mtk.manpages at gmail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mtk.manpages at gmail dot com @ 2012-04-22  1:59 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

Michael Kerrisk <mtk.manpages at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |mtk.manpages at gmail dot
                   |                            |com
         Resolution|FIXED                       |

--- Comment #2 from Michael Kerrisk <mtk.manpages at gmail dot com> 2012-04-22 01:58:14 UTC ---
Actually, is there any reason at all to limit the length of the string? Whay
not parse until NUL? Given that "mode" may be a constructed string, or that
other flags may be added in the future, it seems that arbitrarily limiting the
length of the string to some number of bytes is just setting up both glibc and
userspace bugs for the future.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (3 preceding siblings ...)
  2012-04-22  1:59 ` mtk.manpages at gmail dot com
@ 2012-04-22  2:02 ` mtk.manpages at gmail dot com
  2012-04-22  2:12 ` mtk.manpages at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mtk.manpages at gmail dot com @ 2012-04-22  2:02 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

--- Comment #3 from Michael Kerrisk <mtk.manpages at gmail dot com> 2012-04-22 02:01:46 UTC ---
A similar remark applies for fdopen(), which uses different code for parsing
'mode'.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libc/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (4 preceding siblings ...)
  2012-04-22  2:02 ` mtk.manpages at gmail dot com
@ 2012-04-22  2:12 ` mtk.manpages at gmail dot com
  2012-04-22 10:40 ` [Bug stdio/12685] " jsm28 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mtk.manpages at gmail dot com @ 2012-04-22  2:12 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

--- Comment #4 from Michael Kerrisk <mtk.manpages at gmail dot com> 2012-04-22 02:11:48 UTC ---
Sorry, my original comment should have read:

Actually, is there any reason at all to limit the length of the string? Why
not parse until NUL *or comma*? Given that "mode" may be a constructed string,
or that other flags may be added in the future, it seems that arbitrarily
limiting the length of the string to some number of bytes is just setting up
both glibc and userspace bugs for the future.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug stdio/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (5 preceding siblings ...)
  2012-04-22  2:12 ` mtk.manpages at gmail dot com
@ 2012-04-22 10:40 ` jsm28 at gcc dot gnu.org
  2013-05-09 15:14 ` ondra at iuuk dot mff.cuni.cz
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-04-22 10:40 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |stdio
         AssignedTo|drepper.fsp at gmail dot    |unassigned at sourceware
                   |com                         |dot org

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug stdio/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (6 preceding siblings ...)
  2012-04-22 10:40 ` [Bug stdio/12685] " jsm28 at gcc dot gnu.org
@ 2013-05-09 15:14 ` ondra at iuuk dot mff.cuni.cz
  2013-05-09 16:08 ` bugdal at aerifal dot cx
  2014-06-27 13:30 ` fweimer at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: ondra at iuuk dot mff.cuni.cz @ 2013-05-09 15:14 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

OndrejBilka <ondra at iuuk dot mff.cuni.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ondra at iuuk dot
                   |                            |mff.cuni.cz

--- Comment #5 from OndrejBilka <ondra at iuuk dot mff.cuni.cz> 2013-05-09 15:13:53 UTC ---
Could you specify why do you want comma as terminator?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug stdio/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (7 preceding siblings ...)
  2013-05-09 15:14 ` ondra at iuuk dot mff.cuni.cz
@ 2013-05-09 16:08 ` bugdal at aerifal dot cx
  2014-06-27 13:30 ` fweimer at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: bugdal at aerifal dot cx @ 2013-05-09 16:08 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12685

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2013-05-09 16:08:22 UTC ---
I believe it's to ignore some non-standard syntax certain implementations use
for binding a non-default character encoding at open time. I recall seeing such
a usage before but I can't think where.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug stdio/12685] fopen doesn't honor last byte of valid modes
  2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
                   ` (8 preceding siblings ...)
  2013-05-09 16:08 ` bugdal at aerifal dot cx
@ 2014-06-27 13:30 ` fweimer at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 13:30 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12685

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-06-27 13:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20  0:46 [Bug libc/12685] New: fopen doesn't last byte of valid modes eblake at redhat dot com
2011-04-20  0:47 ` [Bug libc/12685] fopen doesn't honor " eblake at redhat dot com
2011-04-20  0:52 ` ppluzhnikov at google dot com
2011-04-23  3:42 ` drepper.fsp at gmail dot com
2012-04-22  1:59 ` mtk.manpages at gmail dot com
2012-04-22  2:02 ` mtk.manpages at gmail dot com
2012-04-22  2:12 ` mtk.manpages at gmail dot com
2012-04-22 10:40 ` [Bug stdio/12685] " jsm28 at gcc dot gnu.org
2013-05-09 15:14 ` ondra at iuuk dot mff.cuni.cz
2013-05-09 16:08 ` bugdal at aerifal dot cx
2014-06-27 13:30 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).