Opened 12 years ago

Last modified 12 years ago

#4765 closed defect

x64 issue in BT dataset driver — at Version 2

Reported by: murphke1 Owned by: warmerdam
Priority: normal Milestone: 1.9.2
Component: GDAL_Raster Version: 1.9.1
Severity: normal Keywords: bt
Cc:

Description (last modified by warmerdam)

Found what appears to be a GDAL bug today. Attempting to use "gdal_translate" on a 4 Gig BT file. Note that my GDAL code date is 20120516, in case its already been addressed.

In "btdataset.cpp" the line below fails because the conversion to int64 doesn't happen until after the multiply and add. None of the multipliers are int64 so you get integer overflow before the value is converted to int64 when it gets passed in to the function.

/* -------------------------------------------------------------------- */
/*      Seek to profile.                                                */
/* -------------------------------------------------------------------- */
   if( VSIFSeekL( fpImage, 
                  256 + nBlockXOff * nDataSize * nRasterYSize, 
                  SEEK_SET ) != 0 )	
   {
       CPLError( CE_Failure, CPLE_FileIO, 
                 ".bt Seek failed:%s", VSIStrerror( errno ) );
       return CE_Failure;
   }

Replacing it with the below sorted that out. Still trying to process the file - there may be other int64 issues.

/* -------------------------------------------------------------------- */
/*      Seek to profile.                                                */
/* -------------------------------------------------------------------- */
   if( VSIFSeekL( fpImage, 
                  256 + (__int64)nBlockXOff * (__int64)nDataSize * (__int64)nRasterYSize, 
                  SEEK_SET ) != 0 )
   {
       CPLError( CE_Failure, CPLE_FileIO, 
                 ".bt Seek failed:%s", VSIStrerror( errno ) );
       return CE_Failure;
   }

Kevin Murphy

Change History (2)

comment:1 by murphke1, 12 years ago

Component: defaultGDAL_Raster
Version: unspecified1.9.1

comment:2 by warmerdam, 12 years ago

Description: modified (diff)
Keywords: bt added
Status: newassigned
Note: See TracTickets for help on using tickets.