[Gdal-dev] NetCDF driver bug fix

Mario.Cruz at esa.int Mario.Cruz at esa.int
Fri Nov 23 05:51:57 EST 2007


Sorry to revive a seemingly dead thread, but I was revisiting the code 
while upgrading to the now forbidden 1.4.3 release, and realized that the 
submitted patch is seriously ill, i.e. IT DOES NOT WORK for any attribute 
type except strings. Explaining why it does not work is left as an 
exercise for the reader.

Anyway, solved the reported bug with a smaller (and now hopefully 
type-safe) set of changes to the code, but I'll try to follow due 
procedure this time around and submit both the bug and suggested 
correction through the bug tracker system.

My apologies for wasting anyone's time on this issue.

Best regards,

Mario Cruz

> 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
> 


More information about the gdal-dev mailing list