From f7cae7731c9b8fa7d92bd468d5f2fc5b342f21a2 Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Wed, 6 Jun 2018 14:09:28 -0500 Subject: [PATCH] io/ompio: return error code for invalid offset in file_get_byte_offset, return an error code if the offset leads to an invalid position in file. Makes the e_get_byte_offset_1 test from the ibm testsuite pass. Signed-off-by: Edgar Gabriel --- ompi/mca/io/ompio/io_ompio_file_open.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ompi/mca/io/ompio/io_ompio_file_open.c b/ompi/mca/io/ompio/io_ompio_file_open.c index 59197556a1..520e906206 100644 --- a/ompi/mca/io/ompio/io_ompio_file_open.c +++ b/ompi/mca/io/ompio/io_ompio_file_open.c @@ -466,15 +466,18 @@ int mca_io_ompio_file_get_byte_offset (ompi_file_t *fh, { mca_io_ompio_data_t *data; int i, k, index; - size_t temp_offset; + long temp_offset; data = (mca_io_ompio_data_t *) fh->f_io_selected_data; OPAL_THREAD_LOCK(&fh->f_lock); - temp_offset = data->ompio_fh.f_view_extent * + temp_offset = (long) data->ompio_fh.f_view_extent * (offset*data->ompio_fh.f_etype_size / data->ompio_fh.f_view_size); + if ( 0 > temp_offset ) { + OPAL_THREAD_UNLOCK(&fh->f_lock); + return MPI_ERR_ARG; + } - i = (offset*data->ompio_fh.f_etype_size) % data->ompio_fh.f_view_size; index = 0; k = 0;