Skip to content

Commit

Permalink
MiraMonVector: Fix unsigned integer overflows (ossfuzz#68585) (OSGeo#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AbelPau authored May 3, 2024
1 parent 0c3c9f7 commit b254210
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ogr/ogrsf_frmts/miramon/mm_rdlayr.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,23 @@ MMGetMultiPolygonCoordinates(struct MiraMonVectLayerInfo *hMiraMonLayer,

pArcHeader = hMiraMonLayer->MMPolygon.MMArc.pArcHeader +
(hMiraMonLayer->pArcs + nIndex)->nIArc;

if (hMiraMonLayer->ReadFeature
.pNCoordRing[hMiraMonLayer->ReadFeature.nNRings] >
UINT64_MAX - pArcHeader->nElemCount)
{
free_function(pBuffer);
return 1;
}

if (hMiraMonLayer->ReadFeature
.pNCoordRing[hMiraMonLayer->ReadFeature.nNRings] >
UINT64_MAX - pArcHeader->nElemCount)
{
free_function(pBuffer);
return 1;
}

hMiraMonLayer->ReadFeature
.pNCoordRing[hMiraMonLayer->ReadFeature.nNRings] +=
pArcHeader->nElemCount;
Expand Down Expand Up @@ -517,10 +534,19 @@ MMGetMultiPolygonCoordinates(struct MiraMonVectLayerInfo *hMiraMonLayer,
return 1;
}

if (hMiraMonLayer->ReadFeature
.pNCoordRing[hMiraMonLayer->ReadFeature.nNRings] >
UINT64_MAX - hMiraMonLayer->ReadFeature.nNumpCoord)
{
free_function(pBuffer);
return 1;
}

hMiraMonLayer->ReadFeature
.pNCoordRing[hMiraMonLayer->ReadFeature.nNRings] +=
hMiraMonLayer->ReadFeature.nNumpCoord;
nNAcumulVertices += hMiraMonLayer->ReadFeature.nNumpCoord;

if ((hMiraMonLayer->pArcs + nIndex)->VFG & MM_POL_END_RING)
{
hMiraMonLayer->ReadFeature
Expand Down

0 comments on commit b254210

Please sign in to comment.