Skip to content

Commit 01ca438

Browse files
committed
mapshape: check for negative sizes in msSHPReadAllocateBuffer()
Yet another buffer overflow found by libFuzzer.
1 parent b08cf2d commit 01ca438

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mapshape.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ static int msSHPReadAllocateBuffer( SHPHandle psSHP, int hEntity, const char* ps
10191019
{
10201020

10211021
int nEntitySize = msSHXReadSize(psSHP, hEntity);
1022-
if( nEntitySize > INT_MAX - 8 ) {
1022+
if( nEntitySize < 0 || nEntitySize > INT_MAX - 8 ) {
10231023
msSetError(MS_MEMERR, "Out of memory. Cannot allocate %d bytes. Probably broken shapefile at feature %d",
10241024
pszCallingFunction, nEntitySize, hEntity);
10251025
return(MS_FAILURE);

0 commit comments

Comments
 (0)