Skip to content

Commit 15f428c

Browse files
committed
VRTDerivedRasterBand::IRasterIO(): avoid potential int overflow
1 parent fa1fd89 commit 15f428c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

frmts/vrt/vrtderivedrasterband.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,24 @@ CPLErr VRTDerivedRasterBand::IRasterIO(
992992
return CE_Failure;
993993
}
994994

995+
if constexpr (sizeof(GSpacing) > sizeof(int))
996+
{
997+
if (nLineSpace > INT_MAX)
998+
{
999+
if (nBufYSize == 1)
1000+
{
1001+
nLineSpace = 0;
1002+
}
1003+
else
1004+
{
1005+
CPLError(CE_Failure, CPLE_NotSupported,
1006+
"VRTDerivedRasterBand::IRasterIO(): nLineSpace > "
1007+
"INT_MAX not supported");
1008+
return CE_Failure;
1009+
}
1010+
}
1011+
}
1012+
9951013
const int nBufTypeSize = GDALGetDataTypeSizeBytes(eBufType);
9961014
GDALDataType eSrcType = eSourceTransferType;
9971015
if (eSrcType == GDT_Unknown || eSrcType >= GDT_TypeCount)

0 commit comments

Comments
 (0)