This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PR libfortran/62768] Handle filenames with embedded nulls
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 16 Sep 2014 08:53:21 +0300
- Subject: Re: [PR libfortran/62768] Handle filenames with embedded nulls
- Authentication-results: sourceware.org; auth=none
- References: <CAO9iq9E75dJ2AEMfnB_Ro68FBEpYz=BjS2-fxqWNUznbCtpH+Q at mail dot gmail dot com>
Ping.
On Fri, Sep 5, 2014 at 3:54 AM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> Hi,
>
> when opening a file with a name containing an ASCII null character,
> the name is truncated at the first null since the IO API's take
> null-terminated C strings. By storing such a C string in gfc_unit
> instead of the original Fortran string INQUIRE for the file name will
> return the correct name, and the code is simplified slightly. It also
> fixes an bug in open.c(already_open) for the !HAVE_UNLINK_OPEN_FILE
> case in that the file is unlinked before freeing the name (which I
> can't test but seems obvious).
>
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
>
> 2014-09-05 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.
>
>
> --
> Janne Blomqvist
--
Janne Blomqvist