Skip to content

Check input file size against minimum netCDF file size - #247

Open
wkliao wants to merge 5 commits into
Parallel-NetCDF:masterfrom
wkliao:min_fsize
Open

wkliao wants to merge 5 commits into
Parallel-NetCDF:masterfrom
wkliao:min_fsize

Conversation

@wkliao

@wkliao wkliao commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Check a file to be opened its size against the minimum size of netCDF files
and report error code NC_ENOTNC when it is smaller than the minimum.

  • CDF-1 and 2's minimum header size is 32 bytes.
  • CDF-5's minimum header size is 48 bytes.
netcdf_file = header data
header      = magic numrecs dim_list gatt_list var_list
CDF-1/2
              4     4       8        8         8         = 32 bytes
CDF-5
              4     8       12       12        12        = 48 bytes

Delete constant MIN_NC_XSZ from ncmpio_NC.h
Use the three new constants CDF1_MIN_FSIZE, CDF2_MIN_FSIZE, CDF5_MIN_FSIZE
defined in src/include/dispatch.h
The minimum file sizes for CDF-1, 2, and 5 are defined as the followings
in src/include/dispatch.h

  #define CDF1_MIN_FSIZE 32
  #define CDF2_MIN_FSIZE 32
  #define CDF5_MIN_FSIZE 48
Also, add three test netCDF files that contain only the netCDF signature,
to be used for fail tests: bad_min.nc1, bad_min.nc2, and bad_min.nc5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant