Skip to content

Commit

Permalink
Merge pull request #2732 from DennisHeimbigner/corrupt.dmh
Browse files Browse the repository at this point in the history
Fix a crash when accessing a corrupted classic file.
  • Loading branch information
WardF authored Aug 9, 2023
2 parents 2cd9d26 + bb8aa25 commit c374536
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libsrc/posixio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#undef MIN /* system may define MIN somewhere and complain */
#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))

#if !defined(NDEBUG) && !defined(X_INT_MAX)
#if /*!defined(NDEBUG) &&*/ !defined(X_INT_MAX)
#define X_INT_MAX 2147483647
#endif

Expand Down Expand Up @@ -536,9 +536,8 @@ px_get(ncio *const nciop, ncio_px *const pxp,
off_t diff = (size_t)(offset - blkoffset);
off_t blkextent = _RNDUP(diff + extent, pxp->blksz);

assert(extent != 0);
assert(extent < X_INT_MAX); /* sanity check */
assert(offset >= 0); /* sanity check */
if(!(extent != 0 && extent < X_INT_MAX && offset >= 0)) /* sanity check */
return NC_ENOTNC;

if(2 * pxp->blksz < blkextent)
return E2BIG; /* TODO: temporary kludge */
Expand Down
2 changes: 2 additions & 0 deletions nc_test/test_byterange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ ${NCDUMP} -n nc_enddef "$U" >tmp_${TAG}.cdl
diff -wb tmp_$TAG.cdl ${srcdir}/nc_enddef.cdl
}

if test "x$FEATURE_S3TESTS" = xyes ; then
testsetup https://s3.us-east-1.amazonaws.com/unidata-zarr-test-data
fi

echo "*** Testing reading NetCDF-3 file with http"

Expand Down

0 comments on commit c374536

Please sign in to comment.