Opened 14 years ago
Closed 14 years ago
#3481 closed defect (fixed)
Int Overflow when reading large (>2GB) buffer with GDALDataset::RasterIO() : should be allowed when reading juste one band at a time
Reported by: | dowm | Owned by: | warmerdam |
---|---|---|---|
Priority: | high | Milestone: | 1.7.2 |
Component: | GDAL_Raster | Version: | 1.7.1 |
Severity: | normal | Keywords: | TSX COSAR overflow |
Cc: |
Description
Defect appeared between 1.6.3 and 1.7.1.
ERROR 1: Int overflow : 85632 x 27779
-r--r----- 1 root Data 2379336120 2008-06-17 00:40 TerraSAR-X/SPL4735_1_DPL6702_1/TSX1_SARSSCSM_S_SRA_20080513T102455_20080513T102503/IMAGEDATA/IMAGE_VV_SRA_strip_010.cos
code snippet:
int64_t rasterCnt = poDataset->GetRasterCount(); int64_t rows = (poDataset->GetRasterXSize()); int64_t columns = (poDataset->GetRasterYSize()); valarray<complex<int16_t> > dset_data(rows*columns); poDataset->RasterIO( GF_Read, 0, 0, rows, columns, &(dset_data[0]), rows, columns, GDT_CInt16, rasterCnt, NULL, 0, 0, 0);
Change History (1)
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Summary: | Int Overflow when reading large (>2GB) COSAR files → Int Overflow when reading large (>2GB) buffer with GDALDataset::RasterIO() : should be allowed when reading juste one band at a time |
Note:
See TracTickets
for help on using tickets.
Hum, I can now see why it worked before, but you should avoid reading so much data in a single gulp. The warning is true : the nBandSpace parameter certainly overflows for a 85632 x 27779 dataset as the result is > 2 GB and the nBandSpace variable is a signed int32. So if you wanted to read several bands of a multiband dataset of that dimension, the buffer would not be filled correctly. However when reading just one band, the nBandSpace value doesn't matter as unused, so the check is indeed not needed.
You have a workaround with GDAL 1.7.1 : use the RasterIO() at the band level instead.
Note for later (GDAL 2.0), increasing the various spacing variables to be of type size_t would be a good idea to allow reading big buffers in all cases.
Fixed in trunk (r19121) and in branches/1.7 (r19122)