public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/59108] New: ACTION='READ' is using O_CREAT
@ 2013-11-13 10:44 nmm1 at cam dot ac.uk
  2013-11-15 15:55 ` [Bug libfortran/59108] " jvdelisle at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nmm1 at cam dot ac.uk @ 2013-11-13 10:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59108

            Bug ID: 59108
           Summary: ACTION='READ' is using O_CREAT
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nmm1 at cam dot ac.uk

Running 'strace -v -e trace=open' on the following program:

PROGRAM Main
    OPEN(11,FILE='wombat',ACTION='READ')
    OPEN(12,FILE='numbat',ACTION='READ',ACCESS='STREAM')
    OPEN(13,FILE='dingbat',ACTION='READ',ACCESS='DIRECT',RECL=8)
END PROGRAM Main

produces:

open("wombat", O_RDONLY|O_CREAT, 0666)  = 3
open("numbat", O_RDONLY|O_CREAT, 0666)  = 4
open("dingbat", O_RDONLY|O_CREAT, 0666) = 5

Not merely does this create files when the user isn't expecting it,
it fails if the directory or file system is protected against writing.

wheeler$uname -a
Linux wheeler 2.6.37.6-24-desktop #1 SMP PREEMPT 2012-10-18 22:36:08 +0200
x86_64 x86_64 x86_64 GNU/Linux
wheeler$gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/nmm/GCC/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/home/nmm/GCC --disable-bootstrap
--enable-languages=c,c++,fortran --enable-werror=yes --disable-decimal-float
Thread model: posix
gcc version 4.8.1 (GCC)


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

* [Bug libfortran/59108] ACTION='READ' is using O_CREAT
  2013-11-13 10:44 [Bug libfortran/59108] New: ACTION='READ' is using O_CREAT nmm1 at cam dot ac.uk
@ 2013-11-15 15:55 ` jvdelisle at gcc dot gnu.org
  2013-11-15 22:00 ` jb at gcc dot gnu.org
  2013-11-15 23:14 ` jb at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2013-11-15 15:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59108

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot gnu.org

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Proposed patch, testing:

Index: unix.c
===================================================================
--- unix.c    (revision 204616)
+++ unix.c    (working copy)
@@ -1305,6 +1305,10 @@
       break;

     case STATUS_UNKNOWN:
+      crflag = 0;
+      if (flags->action == ACTION_READ)
+    break;
+      /* Fall through.  */
     case STATUS_SCRATCH:
       crflag = O_CREAT;
       break;


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

* [Bug libfortran/59108] ACTION='READ' is using O_CREAT
  2013-11-13 10:44 [Bug libfortran/59108] New: ACTION='READ' is using O_CREAT nmm1 at cam dot ac.uk
  2013-11-15 15:55 ` [Bug libfortran/59108] " jvdelisle at gcc dot gnu.org
@ 2013-11-15 22:00 ` jb at gcc dot gnu.org
  2013-11-15 23:14 ` jb at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jb at gcc dot gnu.org @ 2013-11-15 22:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59108

--- Comment #2 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Fri Nov 15 22:00:36 2013
New Revision: 204864

URL: http://gcc.gnu.org/viewcvs?rev=204864&root=gcc&view=rev
Log:
When file status is unknown, don't set O_CREAT when opening read-only.

2013-11-15  Janne Blomqvist  <jb@gcc.gnu.org>
        Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    PR fortran/59108
    * io/unix.c (regular_file): Don't set O_CREAT when opening a file
    read-only with unknown status. Mask out O_CREAT when falling back
    to opening read-only if ACTION= is not set and read-write fails.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unix.c


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

* [Bug libfortran/59108] ACTION='READ' is using O_CREAT
  2013-11-13 10:44 [Bug libfortran/59108] New: ACTION='READ' is using O_CREAT nmm1 at cam dot ac.uk
  2013-11-15 15:55 ` [Bug libfortran/59108] " jvdelisle at gcc dot gnu.org
  2013-11-15 22:00 ` jb at gcc dot gnu.org
@ 2013-11-15 23:14 ` jb at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jb at gcc dot gnu.org @ 2013-11-15 23:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59108

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jb at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Closing, fixed on trunk (4.9).


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

end of thread, other threads:[~2013-11-15 23:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 10:44 [Bug libfortran/59108] New: ACTION='READ' is using O_CREAT nmm1 at cam dot ac.uk
2013-11-15 15:55 ` [Bug libfortran/59108] " jvdelisle at gcc dot gnu.org
2013-11-15 22:00 ` jb at gcc dot gnu.org
2013-11-15 23:14 ` jb at gcc dot gnu.org

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).