Skip to content

Commit

Permalink
fixed integer overflow in bytesRead (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
edisonguo committed Jul 16, 2021
1 parent a1d9721 commit 327d8ee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion worker/gdalprocess/warp.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func WarpRaster(in *pb.GeoRPCGranule) *pb.Result {
var dstBufC unsafe.Pointer
var noData float64
var dType C.GDALDataType
var bytesReadC C.int
var bytesReadC C.size_t

var resUsage0, resUsage1 syscall.Rusage
syscall.Getrusage(syscall.RUSAGE_SELF, &resUsage0)
Expand Down
4 changes: 2 additions & 2 deletions worker/gdalprocess/warper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int roundCoord(double coord, int maxExtent) {
return c;
}

int warp_operation_fast(const char *srcFilePath, char *srcProjRef, double *srcGeot, const char **geoLocOpts, const char *dstProjRef, double *dstGeot, int dstXImageSize, int dstYImageSize, int band, int srsCf, void **dstBuf, int *dstBufSize, int *dstBbox, double *noData, GDALDataType *dType, int *bytesRead)
int warp_operation_fast(const char *srcFilePath, char *srcProjRef, double *srcGeot, const char **geoLocOpts, const char *dstProjRef, double *dstGeot, int dstXImageSize, int dstYImageSize, int band, int srsCf, void **dstBuf, int *dstBufSize, int *dstBbox, double *noData, GDALDataType *dType, size_t *bytesRead)
{
*bytesRead = 0;

Expand Down Expand Up @@ -331,7 +331,7 @@ int warp_operation_fast(const char *srcFilePath, char *srcProjRef, double *srcGe
blockBuffer.resize(srcXBlockSize * srcYBlockSize * srcDataSize);
uint8_t* blockBuf = blockBuffer.data();

int nBlocksRead = 0;
size_t nBlocksRead = 0;

for(const auto& it : blockPixelMap) {
const int nPixels = it.second.first.size();
Expand Down
2 changes: 1 addition & 1 deletion worker/gdalprocess/warper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
extern "C" {
#endif

int warp_operation_fast(const char *srcFilePath, char *srcProjRef, double *srcGeot, const char **geoLocOpts, const char *dstProjRef, double *dstGeot, int dstXImageSize, int dstYImageSize, int band, int srsCf, void **dstBuf, int *dstBufSize, int *dstBbox, double *noData, GDALDataType *dType, int *bytesRead);
int warp_operation_fast(const char *srcFilePath, char *srcProjRef, double *srcGeot, const char **geoLocOpts, const char *dstProjRef, double *dstGeot, int dstXImageSize, int dstYImageSize, int band, int srsCf, void **dstBuf, int *dstBufSize, int *dstBbox, double *noData, GDALDataType *dType, size_t *bytesRead);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 327d8ee

Please sign in to comment.