1919#include " ogr_srs_api.h"
2020
2121#include < algorithm>
22+ #include < cinttypes>
2223
2324static GInt16 CastToGInt16 (float val)
2425{
@@ -226,10 +227,11 @@ CPLErr SAR_CEOSRasterBand::IReadBlock(int /* nBlockXOff */, int nBlockYOff,
226227
227228 struct CeosSARImageDesc *ImageDesc = &(poGDS->sVolume .ImageDesc );
228229
229- int offset ;
230+ int offsetStart = 0 ;
230231 CalcCeosSARImageFilePosition (&(poGDS->sVolume ), nBand, nBlockYOff + 1 ,
231- nullptr , &offset );
232+ nullptr , &offsetStart );
232233
234+ vsi_l_offset offset = offsetStart;
233235 offset += ImageDesc->ImageDataStart ;
234236
235237 /* -------------------------------------------------------------------- */
@@ -361,9 +363,10 @@ CPLErr CCPRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff,
361363
362364 struct CeosSARImageDesc *ImageDesc = &(poGDS->sVolume .ImageDesc );
363365
364- int offset = ImageDesc->FileDescriptorLength +
365- ImageDesc->BytesPerRecord * nBlockYOff +
366- ImageDesc->ImageDataStart ;
366+ const vsi_l_offset offset =
367+ ImageDesc->FileDescriptorLength +
368+ static_cast <vsi_l_offset>(ImageDesc->BytesPerRecord ) * nBlockYOff +
369+ ImageDesc->ImageDataStart ;
367370
368371 /* -------------------------------------------------------------------- */
369372 /* Load all the pixel data associated with this scanline. */
@@ -377,9 +380,11 @@ CPLErr CCPRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff,
377380 nBytesToRead)
378381 {
379382 CPLError (CE_Failure, CPLE_FileIO,
380- " Error reading %d bytes of CEOS record data at offset %d.\n "
383+ " Error reading %d bytes of CEOS record data at offset %" PRIu64
384+ " .\n "
381385 " Reading file %s failed." ,
382- nBytesToRead, offset, poGDS->GetDescription ());
386+ nBytesToRead, static_cast <uint64_t >(offset),
387+ poGDS->GetDescription ());
383388 CPLFree (pabyRecord);
384389 return CE_Failure;
385390 }
@@ -502,9 +507,10 @@ CPLErr PALSARRasterBand::IReadBlock(int /* nBlockXOff */, int nBlockYOff,
502507
503508 struct CeosSARImageDesc *ImageDesc = &(poGDS->sVolume .ImageDesc );
504509
505- int offset = ImageDesc->FileDescriptorLength +
506- ImageDesc->BytesPerRecord * nBlockYOff +
507- ImageDesc->ImageDataStart ;
510+ const vsi_l_offset offset =
511+ ImageDesc->FileDescriptorLength +
512+ static_cast <vsi_l_offset>(ImageDesc->BytesPerRecord ) * nBlockYOff +
513+ ImageDesc->ImageDataStart ;
508514
509515 /* -------------------------------------------------------------------- */
510516 /* Load all the pixel data associated with this scanline. */
@@ -518,9 +524,11 @@ CPLErr PALSARRasterBand::IReadBlock(int /* nBlockXOff */, int nBlockYOff,
518524 nBytesToRead)
519525 {
520526 CPLError (CE_Failure, CPLE_FileIO,
521- " Error reading %d bytes of CEOS record data at offset %d.\n "
527+ " Error reading %d bytes of CEOS record data at offset %" PRIu64
528+ " .\n "
522529 " Reading file %s failed." ,
523- nBytesToRead, offset, poGDS->GetDescription ());
530+ nBytesToRead, static_cast <uint64_t >(offset),
531+ poGDS->GetDescription ());
524532 CPLFree (pabyRecord);
525533 return CE_Failure;
526534 }
@@ -1712,7 +1720,8 @@ void SAR_CEOSDataset::ScanForGCPs()
17121720 &nFileOffset);
17131721
17141722 GInt32 anRecord[192 / 4 ];
1715- if (VSIFSeekL (fpImage, nFileOffset, SEEK_SET) != 0 ||
1723+ if (VSIFSeekL (fpImage, static_cast <vsi_l_offset>(nFileOffset),
1724+ SEEK_SET) != 0 ||
17161725 VSIFReadL (anRecord, 1 , 192 , fpImage) != 192 )
17171726 break ;
17181727
@@ -2169,7 +2178,7 @@ static int ProcessData(VSILFILE *fp, int fileid, CeosSARVolume_t *sar,
21692178{
21702179 unsigned char temp_buffer[CEOS_HEADER_LENGTH];
21712180 unsigned char *temp_body = nullptr ;
2172- int start = 0 ;
2181+ vsi_l_offset start = 0 ;
21732182 int CurrentBodyLength = 0 ;
21742183 int CurrentType = 0 ;
21752184 int CurrentSequence = 0 ;
0 commit comments