You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Observe that, for this file, which contains the TimeInterval global attribute, ncplot does not crash when attempting to view a variable.
Remove the TimeInterval global attribute using ncatted (from the NetCDF Operators package):
ncatted -a TimeInterval,global,d,, test.nc noti.nc
Run
ncplot noti.nc
and observe that ncplot will crash the moment the user attempts to view a variable.
Cause
The GetTimeInterval function in in dataIO.c on lines 854-882 reads and parses the TimeInterval NetCDF global attribute to obtain the start and end time. From here, FileStartTime and FileEndTime members of the curFile struct are set. These values are later used to populate the UserStartTime and UserEndTime variables in dataIO.c:
if (timeSeg) /* From command line only */
{
// ... snip ...
}
else
{
memcpy((char *)UserStartTime, (char *)curFile->FileStartTime,4*sizeof(int));
memcpy((char *)UserEndTime, (char *)curFile->FileEndTime,4*sizeof(int));
}
which are then used, in turn, to compute a value NumberSeconds,
which ultimately causes the crash (due to a division by zero error) on line 490 in X.c:
halfSecond = plot->x.HD / NumberSeconds / 2;
Mitigation strategies
This would be avoidable if the start and end times were not read from the NetCDF file as an attribute, but computed from the Time field itself.
Desired behavior
Ideally, ncplot would at least warn the user that the TimeInterval global attribute must be present; i.e., ncplot should throw an error if the TimeInterval global attribute is not present.
The text was updated successfully, but these errors were encountered:
Issue
If a NetCDF file is opened in ncplot that is missing a (properly defined)
TimeInterval
global attribute, ncplot will crash with this messagethe moment the user attempts to view a variable by selecting it from the list of all variables in the file.
Steps to reproduce
Download the test file contained in test.zip.
Invoke ncplot with
Observe that, for this file, which contains the
TimeInterval
global attribute,ncplot
does not crash when attempting to view a variable.Remove the TimeInterval global attribute using
ncatted
(from the NetCDF Operators package):Run
and observe that ncplot will crash the moment the user attempts to view a variable.
Cause
The
GetTimeInterval
function in indataIO.c
on lines 854-882 reads and parses theTimeInterval
NetCDF global attribute to obtain the start and end time. From here,FileStartTime
andFileEndTime
members of thecurFile
struct are set. These values are later used to populate theUserStartTime
andUserEndTime
variables in dataIO.c:which are then used, in turn, to compute a value
NumberSeconds
,which ultimately causes the crash (due to a division by zero error) on line 490 in
X.c
:Mitigation strategies
This would be avoidable if the start and end times were not read from the NetCDF file as an attribute, but computed from the Time field itself.
Desired behavior
Ideally, ncplot would at least warn the user that the
TimeInterval
global attribute must be present; i.e., ncplot should throw an error if theTimeInterval
global attribute is not present.The text was updated successfully, but these errors were encountered: