Merge pull request #2732 from DennisHeimbigner/corrupt.dmh

Fix a crash when accessing a corrupted classic file.
This commit is contained in:
Ward Fisher 2023-08-09 15:48:31 -06:00 committed by GitHub
commit c374536240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -63,7 +63,7 @@
#undef MIN /* system may define MIN somewhere and complain */ #undef MIN /* system may define MIN somewhere and complain */
#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn)) #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 #define X_INT_MAX 2147483647
#endif #endif
@ -536,9 +536,8 @@ px_get(ncio *const nciop, ncio_px *const pxp,
off_t diff = (size_t)(offset - blkoffset); off_t diff = (size_t)(offset - blkoffset);
off_t blkextent = _RNDUP(diff + extent, pxp->blksz); off_t blkextent = _RNDUP(diff + extent, pxp->blksz);
assert(extent != 0); if(!(extent != 0 && extent < X_INT_MAX && offset >= 0)) /* sanity check */
assert(extent < X_INT_MAX); /* sanity check */ return NC_ENOTNC;
assert(offset >= 0); /* sanity check */
if(2 * pxp->blksz < blkextent) if(2 * pxp->blksz < blkextent)
return E2BIG; /* TODO: temporary kludge */ return E2BIG; /* TODO: temporary kludge */

View File

@ -86,7 +86,9 @@ ${NCDUMP} -n nc_enddef "$U" >tmp_${TAG}.cdl
diff -wb tmp_$TAG.cdl ${srcdir}/nc_enddef.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 testsetup https://s3.us-east-1.amazonaws.com/unidata-zarr-test-data
fi
echo "*** Testing reading NetCDF-3 file with http" echo "*** Testing reading NetCDF-3 file with http"