Skip to content

Commit 0761c0b

Browse files
committed
common_ompio_file_set_view: recognize negative disp in access
you cannot access parts of a file if the file view contains a description that leads ultimately to a negative offset. This fix ensures that we return an error in this case (MPI_ERR_IO). This fix was triggered by an investigation into mpich/test/mpi/io/tst_fileview testcase. Running this test with ompio still leads to a number of 'failures' since we return MPI_ERR_TYPE in some instances, while the testcode expects MPI_ERR_IO. I will not fix those issues, since this is like playing guacamole (fixing the error code expected by one testsuite makes another testsuite fail). However, this commit fixes the one case where we returned MPI_SUCCESS instead of an error code. Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>
1 parent 79561ee commit 0761c0b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ompi/mca/common/ompio/common_ompio_file_view.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,17 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
177177
// File view is not a multiple of the etype.
178178
return MPI_ERR_ARG;
179179
}
180+
181+
// make sure that displacement is not negative, which could
182+
// lead to an illegal access.
183+
if ( 0 < fh->f_iov_count && 0 > (off_t)fh->f_decoded_iov[0].iov_base ) {
184+
// I think MPI_ERR_TYPE would be more appropriate, but
185+
// this is the error code expected in a testsuite, so I just
186+
// go with this.
187+
return MPI_ERR_IO;
188+
}
180189

190+
181191
if( SIMPLE_PLUS == OMPIO_MCA_GET(fh, grouping_option) ) {
182192
fh->f_cc_size = get_contiguous_chunk_size (fh, 1);
183193
}

0 commit comments

Comments
 (0)