Skip to content

Commit e27a13e

Browse files
author
Grok Compression
committed
readSOT: sanity check on tile index
1 parent 5aa201c commit e27a13e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/lib/core/codestream/decompress/CodeStreamDecompress_ReadMarkers.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,14 @@ bool CodeStreamDecompress::readSOT(uint8_t* headerData, uint16_t headerSize)
358358
}
359359
uint16_t tileIndex;
360360
grk_read(&headerData, &tileIndex);
361+
362+
uint16_t totalTiles = cp_.t_grid_width_ * cp_.t_grid_height_;
363+
if(tileIndex >= totalTiles)
364+
{
365+
grklog.error("readSOT: tile index %d lies outside tile grid %d x %d", tileIndex,
366+
cp_.t_grid_width_, cp_.t_grid_height_);
367+
return false;
368+
}
361369
currTileIndex_ = tileIndex;
362370

363371
grk_read(&headerData, &currTilePartInfo_.tilePartLength_);

0 commit comments

Comments
 (0)