Commit f152a228 authored by Karl Wette's avatar Karl Wette

LatticeTiling: extra safety check on index when restoring iterator

Original: dde2e9909b5237e4ccb6959f0c1d3616a60128e4
parent 6b7088a1
......@@ -2026,13 +2026,12 @@ int XLALSaveLatticeTilingIterator(
} {
UINT4 state = itr->state;
XLAL_CHECK( XLALFITSHeaderWriteUINT4( file, "state", state, "iterator state" ) == XLAL_SUCCESS, XLAL_EFUNC );
} {
UINT8 indx = itr->index;
XLAL_CHECK( XLALFITSHeaderWriteUINT8( file, "index", indx, "index of current lattice tiling point" ) == XLAL_SUCCESS, XLAL_EFUNC );
} {
UINT8 count = XLALTotalLatticeTilingPoints( itr );
XLAL_CHECK( count > 0, XLAL_EFUNC );
XLAL_CHECK( XLALFITSHeaderWriteUINT8( file, "count", count, "total number of lattice tiling points" ) == XLAL_SUCCESS, XLAL_EFUNC );
UINT8 indx = itr->index;
XLAL_CHECK( XLALFITSHeaderWriteUINT8( file, "index", indx, "index of current lattice tiling point" ) == XLAL_SUCCESS, XLAL_EFUNC );
}
return XLAL_SUCCESS;
......@@ -2098,10 +2097,6 @@ int XLALRestoreLatticeTilingIterator(
UINT4 state;
XLAL_CHECK( XLALFITSHeaderReadUINT4( file, "state", &state ) == XLAL_SUCCESS, XLAL_EFUNC );
itr->state = state;
} {
UINT8 indx;
XLAL_CHECK( XLALFITSHeaderReadUINT8( file, "index", &indx ) == XLAL_SUCCESS, XLAL_EFUNC );
itr->index = indx;
} {
UINT8 count;
XLAL_CHECK( XLALFITSHeaderReadUINT8( file, "count", &count ) == XLAL_SUCCESS, XLAL_EFUNC );
......@@ -2109,6 +2104,10 @@ int XLALRestoreLatticeTilingIterator(
UINT8 count_ref = XLALTotalLatticeTilingPoints( itr );
XLAL_CHECK( count_ref > 0, XLAL_EFUNC );
XLAL_CHECK( count == count_ref, XLAL_EIO, "Could not restore iterator; invalid HDU '%s'", name );
UINT8 indx;
XLAL_CHECK( XLALFITSHeaderReadUINT8( file, "index", &indx ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK( indx < count_ref, XLAL_EIO, "Could not restore iterator; invalid HDU '%s'", name );
itr->index = indx;
}
// Read FITS records from table
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment