Skip to content

Commit c7c75e0

Browse files
committed
Add duplicate validation
There is validation for tile descriptions already when looking at a tiled file, but if someone provides a tile description in a non-tiled file, validate that the enums will be valid Signed-off-by: Kimball Thurston <[email protected]>
1 parent 90704f2 commit c7c75e0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/lib/OpenEXRCore/parse_header.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,7 @@ check_populate_tiles (
13961396
{
13971397
exr_result_t rv;
13981398
exr_attr_tiledesc_t tmpdata = {0};
1399+
uint8_t lev, rnd;
13991400

14001401
if (curpart->tiles)
14011402
{
@@ -1434,6 +1435,25 @@ check_populate_tiles (
14341435
tmpdata.x_size = one_to_native32 (tmpdata.x_size);
14351436
tmpdata.y_size = one_to_native32 (tmpdata.y_size);
14361437

1438+
lev = tmpdata.level_and_round & 0xF;
1439+
rnd = (tmpdata.level_and_round >> 4) & 0xF;
1440+
if (lev >= (uint8_t)EXR_TILE_LAST_TYPE)
1441+
{
1442+
return ctxt->print_error (
1443+
ctxt,
1444+
EXR_ERR_INVALID_ATTR,
1445+
"Invalid level mode (%d) in tile description header",
1446+
(int) lev);
1447+
}
1448+
if (rnd >= (uint8_t)EXR_TILE_ROUND_LAST_TYPE)
1449+
{
1450+
return ctxt->print_error (
1451+
ctxt,
1452+
EXR_ERR_INVALID_ATTR,
1453+
"Invalid rounding mode (%d) in tile description header",
1454+
(int) rnd);
1455+
}
1456+
14371457
rv = exr_attr_list_add_static_name (
14381458
ctxt,
14391459
&(curpart->attributes),

0 commit comments

Comments
 (0)