This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Beth, >I don't know if you have run across this error or not, but >in local_nc.h the memory for the path field is not being allocated >correctly. The path field is currently set to be FILENAME_MAX >which varies on different systems (sometimes less than 255) and MAXPATHLEN >is 255. > >The strncpy routine in file.c pads to MAXPATHLEN on non-null terminated >strings. Because the path field wasn't allocated correctly, memory was >getting clobbered and causing the software to seg fault. > >Our fix was to change the path field to be MAXPATHLEN and set MAXPATHLEN >to more realistic values for the systems we were using. I included >the fix below. Thanks for reporting this. We apparently had discovered this bug previously and fixed it by eliminating the use of MAXPATHLEN in favor of FILENAME_MAX everywhere in the netCDF source code. I'm surprised you saw this bug, since the use of MAXPATHLEN was apparently eliminated from the netCDF 2.3 distribution over a year ago. Perhaps you are looking at an older version of the source? The version of local_nc.h that is in the current netCDF 2.3.2 version is from April 27 1993: /* $Id: local_nc.h,v 1.39 1993/04/27 20:05:21 davis Exp $ */ -- Russ Rew UCAR Unidata Program address@hidden P.O. Box 3000 http://www.unidata.ucar.edu/ Boulder, CO 80307-3000