[Gdal-dev] NetCDF driver bug fix

Mario.Cruz at esa.int Mario.Cruz at esa.int
Tue Oct 16 10:57:42 EDT 2007


Attached follows a (seemingly) working patch for the NetCDF driver.

The ReadAttributes method was using a fixed-length array to store 
attribute data, crashing when presented with an attribute whose data size 
was larger than MAX_STR_LEN.

The patched version dynamically allocates enough memory to store the 
attribute's string representation. It's a naive implementation, but it's 
working well with the datasets I've been throwing at it. And anything is 
better than fixed-length arrays + unknown-length strcpy.

Some remarks:
- array pointer arithmetic done by hand, may impact platform portability
- didn't have time to check for similar bugs in the rest of the driver
- patched against 1.4.2 version
- couldn't figure out if the code uses tabs/spaces or some evil 
combination of both, so just spaced all the indentation

On a related note, is there any reason why variables with only one 
dimension can't be made available as rasters of x*1 size? Didn't really 
want to be adding yet another python module just to access that kind of 
data.

Best regards, 

Mario Cruz


-------------- next part --------------
A non-text attachment was scrubbed...
Name: netcdf.patch
Type: application/octet-stream
Size: 5785 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20071016/835f7688/netcdf.obj


More information about the Gdal-dev mailing list