public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/62768] New: Handling of file names with embedded nulls
@ 2014-09-02 7:14 jb at gcc dot gnu.org
2014-09-02 8:51 ` [Bug spam/62768] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2014-09-02 7:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62768
Bug ID: 62768
Summary: Handling of file names with embedded nulls
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jb at gcc dot gnu.org
libgfortran uses various C/POSIX functions for interfacing with the file
systems. In the C/POSIX world, file names are terminated by a null byte,
whereas Fortran strings are not. Consider
program nullfile
implicit none
character(len=100) :: s = "hello" // achar(0) // "world", &
r
open(10, file=s)
inquire(unit=10, name=r)
print *, r
end program nullfile
This program will create a file named "hello", but the inquire will report that
the name is "hello\0world" as that was the Fortran string that was originally
fed to the open statement.
Storing the null-terminated C name in gfc_unit instead of the Fortran string
would fix this, and also save a bunch of malloc/free calls lower in the IO
stack.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug spam/62768] Handling of file names with embedded nulls
2014-09-02 7:14 [Bug libfortran/62768] New: Handling of file names with embedded nulls jb at gcc dot gnu.org
@ 2014-09-02 8:51 ` pinskia at gcc dot gnu.org
2014-09-02 8:52 ` [Bug libfortran/62768] " pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-09-02 8:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62768
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|libfortran |spam
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libfortran/62768] Handling of file names with embedded nulls
2014-09-02 7:14 [Bug libfortran/62768] New: Handling of file names with embedded nulls jb at gcc dot gnu.org
2014-09-02 8:51 ` [Bug spam/62768] " pinskia at gcc dot gnu.org
@ 2014-09-02 8:52 ` pinskia at gcc dot gnu.org
2014-09-16 21:41 ` jb at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-09-02 8:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62768
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Component|spam |libfortran
Resolution|INVALID |---
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Whoops.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libfortran/62768] Handling of file names with embedded nulls
2014-09-02 7:14 [Bug libfortran/62768] New: Handling of file names with embedded nulls jb at gcc dot gnu.org
2014-09-02 8:51 ` [Bug spam/62768] " pinskia at gcc dot gnu.org
2014-09-02 8:52 ` [Bug libfortran/62768] " pinskia at gcc dot gnu.org
@ 2014-09-16 21:41 ` jb at gcc dot gnu.org
2014-09-17 21:44 ` jb at gcc dot gnu.org
2014-09-27 8:57 ` fxcoudert at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2014-09-16 21:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62768
--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Tue Sep 16 21:40:28 2014
New Revision: 215307
URL: https://gcc.gnu.org/viewcvs?rev=215307&root=gcc&view=rev
Log:
PR libfortran/62768 Handle filenames with embedded null characters.
testsuite ChangeLog:
2014-09-17 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/62768
* gfortran.dg/filename_null.f90: New test.
libgfortran ChangeLog:
2014-09-17 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/62768
* io/io.h (gfc_unit): Store C string for the filename.
* io/close.c (st_close): Use gfc_unit.filename.
* io/inquire.c (inquire_via_unit): Likewise.
* io/open.c (new_unit): Likewise.
(already_open): Likewise, unlink file before freeing filename.
* io/unit.c (init_units): Likewise.
(close_unit_1): Likewise.
(filename_from_unit): Likewise.
* io/unix.c (compare_file_filename): Likewise.
(find_file0): Likewise.
(delete_file): Likewise.
Added:
trunk/gcc/testsuite/gfortran.dg/filename_null.f90
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/close.c
trunk/libgfortran/io/inquire.c
trunk/libgfortran/io/io.h
trunk/libgfortran/io/open.c
trunk/libgfortran/io/unit.c
trunk/libgfortran/io/unix.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libfortran/62768] Handling of file names with embedded nulls
2014-09-02 7:14 [Bug libfortran/62768] New: Handling of file names with embedded nulls jb at gcc dot gnu.org
` (2 preceding siblings ...)
2014-09-16 21:41 ` jb at gcc dot gnu.org
@ 2014-09-17 21:44 ` jb at gcc dot gnu.org
2014-09-27 8:57 ` fxcoudert at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2014-09-17 21:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62768
--- Comment #4 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Wed Sep 17 21:44:15 2014
New Revision: 215338
URL: https://gcc.gnu.org/viewcvs?rev=215338&root=gcc&view=rev
Log:
PR libfortran/62768 Use gfc_unit.filename also when HAVE_TTYNAME{_R} is not
defined.
2014-09-18 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/62768
* io/inquire.c (inquire_via_unit): Use gfc_unit.filename also when
HAVE_TTYNAME{_R} is not defined.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/inquire.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libfortran/62768] Handling of file names with embedded nulls
2014-09-02 7:14 [Bug libfortran/62768] New: Handling of file names with embedded nulls jb at gcc dot gnu.org
` (3 preceding siblings ...)
2014-09-17 21:44 ` jb at gcc dot gnu.org
@ 2014-09-27 8:57 ` fxcoudert at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2014-09-27 8:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62768
Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |fxcoudert at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #5 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-27 8:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 7:14 [Bug libfortran/62768] New: Handling of file names with embedded nulls jb at gcc dot gnu.org
2014-09-02 8:51 ` [Bug spam/62768] " pinskia at gcc dot gnu.org
2014-09-02 8:52 ` [Bug libfortran/62768] " pinskia at gcc dot gnu.org
2014-09-16 21:41 ` jb at gcc dot gnu.org
2014-09-17 21:44 ` jb at gcc dot gnu.org
2014-09-27 8:57 ` fxcoudert 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).