Skip to content

Commit

Permalink
mapshape: check for negative sizes in msSHPReadAllocateBuffer()
Browse files Browse the repository at this point in the history
Yet another buffer overflow found by libFuzzer.
  • Loading branch information
MaxKellermann committed Oct 5, 2021
1 parent 67fb0e8 commit 556a728
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mapshape.c
Expand Up @@ -993,7 +993,7 @@ static int msSHPReadAllocateBuffer( SHPHandle psSHP, int hEntity, const char* ps
{

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

0 comments on commit 556a728

Please sign in to comment.