Opened 14 years ago

Closed 14 years ago

#2000 closed defect (fixed)

use of uninitialized memory in netCDFDataset::SetProjection

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords: netcdf
Cc: dnadeau


Running Valgrind on autotest/gdrivers/ gives the following warning:

==14014== Use of uninitialised value of size 4
==14014==    at 0x40C9390: (within /lib/tls/i686/cmov/
==14014==    by 0x40D1ABA: __printf_fp (in /lib/tls/i686/cmov/
==14014==    by 0x40CBAE6: vfprintf (in /lib/tls/i686/cmov/
==14014==    by 0x40E933B: vsprintf (in /lib/tls/i686/cmov/
==14014==    by 0x40D49BD: sprintf (in /lib/tls/i686/cmov/
==14014==    by 0x493AA92: OGRPrintDouble(char*, double) (ogrspatialreference.cpp:50)
==14014==    by 0x493CBC8: OGRSpatialReference::SetProjParm(char const*, double) (ogrspatialreference.cpp:2361)
==14014==    by 0x493FC03: OGRSpatialReference::SetNormProjParm(char const*, double) (ogrspatialreference.cpp:2612)
==14014==    by 0x4943F36: OGRSpatialReference::SetTM(double, double, double, double, double) (ogrspatialreference.cpp:2642)
==14014==    by 0x467E344: netCDFDataset::SetProjection(int) (netcdfdataset.cpp:795)
==14014==    by 0x4682491: netCDFDataset::Open(GDALOpenInfo*) (netcdfdataset.cpp:1711)
==14014==    by 0x477C275: GDALOpen (gdaldataset.cpp:1774)
==14014==    by 0x467CF17: NCDFCreateCopy(char const*, GDALDataset*, int, char**, int (*)(double, char const*, void*), void*) (netcdfdataset.cpp:2457)
==14014==    by 0x478180F: GDALDriver::CreateCopy(char const*, GDALDataset*, int, char**, int (*)(double, char const*, void*), void*) (gdaldriver.cpp:531)

A quick read of netCDFDataset::SetProjection? shows that in that context dfScale is passed to oSRS.SetTM() without being initialized. (That could also true for the other parameters)

Change History (1)

comment:1 Changed 14 years ago by warmerdam

Cc: dnadeau added
Resolution: fixed
Status: newclosed

Fixed in r12878 which also substantially simplifies projection handling, and stops attaching a copy of "geolocation" metadata to the dataset that largely duplicates what is already in the SRS. Also fixes a few typos in the projection parameters (which lead to the issue noted in this bug).

Note: See TracTickets for help on using tickets.