[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error in netcdf 2.3.2
- Subject: Re: Error in netcdf 2.3.2
- Date: Tue, 28 Jun 1994 08:21:40 -0600
>From: Beth Henderson <address@hidden>
>Organization: Research Systems
>Keywords: 199406241439.AA19966 netCDF header file
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,
>
>Beth Henderson
>Research Systems
>(303)786-9900
>
>
>
>-------------------------------------------
>#ifdef MAXPATHLEN
>#undef MAXPATHLEN
>#endif
>#ifdef VMS
>#define MAXPATHLEN 264 /* That's what VMS allows (+
>slop) */
>#endif
>#ifdef unix
>#define MAXPATHLEN 1024 /* That's what BSD allows */
>#endif
>#ifdef MS_WIN
>#define MAXPATHLEN 64
>#endif
>#ifdef MAC
>#define MAXPATHLEN 255
>#endif
>#endif
>
>
>
>typedef struct {
>#if 0
> char path[FILENAME_MAX + 1] ;
>#else
> char path[MAXPATHLEN + 1] ; /* Correct Allocation */
>#endif
> unsigned flags ;
> XDR *xdrs ;
> long begin_rec ; /* (off_t) postion of the first 'record' */
> unsigned long recsize ; /* length of 'record' */
> int redefid ;
> /* below gets xdr'd */
> unsigned long numrecs ; /* number of 'records' allocated */
> NC_array *dims ;
> NC_array *attrs ;
> NC_array *vars ;
>} NC ;
>
I have forwarded your comments to Russ Rew, who is currently on vacation,
for comment/action.
Tom Yoksas