mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-11 16:40:36 +08:00
fix issue 791: validate ncid for classic files
This commit is contained in:
parent
b850482b8e
commit
cb7aafa805
@ -88,6 +88,11 @@ find_in_NCList(int ext_ncid)
|
||||
unsigned int ncid = ((unsigned int)ext_ncid) >> ID_SHIFT;
|
||||
if(numfiles > 0 && nc_filelist != NULL && ncid < NCFILELISTLENGTH)
|
||||
f = nc_filelist[ncid];
|
||||
|
||||
/* for classic files, ext_ncid must be a multiple of (1<<ID_SHIFT) */
|
||||
if (f != NULL && f->model == NC_FORMATX_NC3 && (ext_ncid % (1<<ID_SHIFT)))
|
||||
return NULL;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ main(int argc, char **argv)
|
||||
/* Create a netcdf-3 file with one dim. */
|
||||
if (nc_create(FILE_NAME, 0, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, LAT_NAME, LAT_LEN, &dimid)) ERR;
|
||||
if (nc_def_dim(ncid + TEST_VAL_42, LAT_NAME, LAT_LEN, &dimid) != NC_EBADID) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and make sure nc_inq_dimids yeilds correct
|
||||
|
Loading…
Reference in New Issue
Block a user