diff options
| author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-16 21:40:28 +0000 |
|---|---|---|
| committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-16 21:40:28 +0000 |
| commit | 8d832ee40150dc53add764cb067cbeb7afcf593e (patch) | |
| tree | 34b3e91356fc23c2feb76d92e78fad28bd83a126 /libgfortran/io/unix.c | |
| parent | ad1321db5a15a7b784660be5f356c8c76cf19af9 (diff) | |
| download | gcc-8d832ee40150dc53add764cb067cbeb7afcf593e.tar.gz | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215307 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io/unix.c')
| -rw-r--r-- | libgfortran/io/unix.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 9ad293b60a4..d30c6e5e33a 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -1525,11 +1525,7 @@ compare_file_filename (gfc_unit *u, const char *name, int len) goto done; } # endif - - if (len != u->file_len) - ret = 0; - else - ret = (memcmp(path, u->file, len) == 0); + ret = (strcmp(path, u->filename) == 0); #endif done: free (path); @@ -1541,8 +1537,8 @@ compare_file_filename (gfc_unit *u, const char *name, int len) # define FIND_FILE0_DECL struct stat *st # define FIND_FILE0_ARGS st #else -# define FIND_FILE0_DECL uint64_t id, const char *file, gfc_charlen_type file_len -# define FIND_FILE0_ARGS id, file, file_len +# define FIND_FILE0_DECL uint64_t id, const char *path +# define FIND_FILE0_ARGS id, path #endif /* find_file0()-- Recursive work function for find_file() */ @@ -1574,7 +1570,7 @@ find_file0 (gfc_unit *u, FIND_FILE0_DECL) } else # endif - if (compare_string (u->file_len, u->file, file_len, file) == 0) + if (strcmp (u->filename, path) == 0) return u; #endif @@ -1718,10 +1714,7 @@ flush_all_units (void) int delete_file (gfc_unit * u) { - char *path = fc_strdup (u->file, u->file_len); - int err = unlink (path); - free (path); - return err; + return unlink (u->filename); } |
