diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-04 20:36:52 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-04 20:36:52 +0000 |
commit | 433b226c1549b4d2dd4a7ad7d07792b4db922851 (patch) | |
tree | 980246c419799542558dca9b884df6c9e3881e82 /libgfortran/io | |
parent | 4a00db2fedf5f75864b94a1b3c65e853dd5a646d (diff) | |
download | gcc-433b226c1549b4d2dd4a7ad7d07792b4db922851.tar.gz |
2005-09-04 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/23321
* io/transfer.c(data_transfer_init): Check for a too-large
record number. Return if sseek failed.
2005-09-04 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/23321
* gfortran.dg/direct_io_4.f90: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103835 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/transfer.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 7449f02d3dd..59eb22d3dec 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1160,10 +1160,23 @@ data_transfer_init (int read_flag) if (g.mode == READING && current_unit->mode == WRITING) flush(current_unit->s); + /* Check whether the record exists to be read. Only + a partial record needs to exist. */ + + if (g.mode == READING && (ioparm.rec -1) + * current_unit->recl >= file_length (current_unit->s)) + { + generate_error (ERROR_BAD_OPTION, "Non-existing record number"); + return; + } + /* Position the file. */ if (sseek (current_unit->s, (ioparm.rec - 1) * current_unit->recl) == FAILURE) - generate_error (ERROR_OS, NULL); + { + generate_error (ERROR_OS, NULL); + return; + } } /* Overwriting an existing sequential file ? |