Ticket #2777 (closed defect: fixed)

Opened 4 years ago

Last modified 3 weeks ago

Problem with gcps count in BSB Driver

Reported by: valisystem Owned by: chaitanya
Priority: normal Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: BSB
Cc: warmerdam, chaitanya

Description

the function BSBDataset::ScanForGCPs() sets a limit (MAX_GCP) for gcps number for allocation, but the implementation reads data and sets nGCPCount beyond that limit, so that GDALDataset->GetGCPs() returns corrupted (overwritten) data over the 256 limit.

See the map 14500_1 in the noaa RNC BSB nautical charts as an example.

Attachments

bsbdataset.patch Download (2.3 KB) - added by chaitanya 4 years ago.
Made the GCP list dynamically sized

Change History

Changed 4 years ago by warmerdam

  • cc warmerdam added
  • keywords BSB added; corrupted data bsb kap gcps removed
  • component changed from default to GDAL_Raster
  • owner changed from warmerdam to chaitanya

Hi,

Could you provide a direct pointer (url) to an example BSB demonstrating this problem?

Chaitanya, please reproduce the problem once a dataset is available, and prepare a proposed patch.

Changed 4 years ago by valisystem

 14500_1.KAP (use save link as)

Note that i discovered this bug while using the GDAL API, but a symptom is segfault/malloc warning with gdalinfo on the file.

Another file with more than 256 gcps is 16568_1.KAP (from the noaa rncs).

Changed 4 years ago by chaitanya

  • cc chaitanya added

Frank, The functions

BSBDataset::ScanForGCPsBSB()

and

BSBDataset::ScanForGCPsNos( const char *pszFilename )

are ignoring the

#define MAX_GCP 256

value. They should compare the

nGCPCount

value with MAX_GCP in their for-loop and while-loop respectively and stop scanning further. Otherwise, I can write some code to make the nGCPCount flexible?

Changed 4 years ago by warmerdam

Chaitanya,

Please prepare a patch making the GCP list dynamically sized. Try to properly use GDALInitGCPs() to intialize extended portions of the gcp array so that future changes in the structure will be ok even if we don't revisit the BSB driver.

Changed 4 years ago by chaitanya

Made the GCP list dynamically sized

Changed 4 years ago by rouault

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 1.5.5

Chaitanya,

I've applied your patch in trunk in r16166, in branches/1.6 in r16167 and in branches/1.5 in r16168.

While reviewing surrounding code, I've also found some security or memory usage problems that I've also fixed in those commits.

Changed 3 weeks ago by rouault

  • milestone 1.5.5 deleted

Milestone 1.5.5 deleted

Note: See TracTickets for help on using tickets.