Skip to content

Commit

Permalink
Add duplicate validation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kdt3rd committed Sep 19, 2024
1 parent 90704f2 commit c7c75e0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lib/OpenEXRCore/parse_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,7 @@ check_populate_tiles (
{
exr_result_t rv;
exr_attr_tiledesc_t tmpdata = {0};
uint8_t lev, rnd;

if (curpart->tiles)
{
Expand Down Expand Up @@ -1434,6 +1435,25 @@ check_populate_tiles (
tmpdata.x_size = one_to_native32 (tmpdata.x_size);
tmpdata.y_size = one_to_native32 (tmpdata.y_size);

lev = tmpdata.level_and_round & 0xF;
rnd = (tmpdata.level_and_round >> 4) & 0xF;
if (lev >= (uint8_t)EXR_TILE_LAST_TYPE)
{
return ctxt->print_error (
ctxt,
EXR_ERR_INVALID_ATTR,
"Invalid level mode (%d) in tile description header",
(int) lev);
}
if (rnd >= (uint8_t)EXR_TILE_ROUND_LAST_TYPE)
{
return ctxt->print_error (
ctxt,
EXR_ERR_INVALID_ATTR,
"Invalid rounding mode (%d) in tile description header",
(int) rnd);
}

rv = exr_attr_list_add_static_name (
ctxt,
&(curpart->attributes),
Expand Down

0 comments on commit c7c75e0

Please sign in to comment.