Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refined validation checks #1828

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/OpenEXRCore/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,9 @@ exr_uncompress_chunk (exr_decode_pipeline_t* decode)
if ((decode->decode_flags & EXR_DECODE_SAMPLE_DATA_ONLY)) return rv;
}

if (rv == EXR_ERR_SUCCESS)
if (rv == EXR_ERR_SUCCESS &&
decode->chunk.packed_size > 0 &&
decode->chunk.unpacked_size > 0)
rv = decompress_data (
ctxt,
part->comp_type,
Expand Down
16 changes: 13 additions & 3 deletions src/lib/OpenEXRCore/decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ default_read_chunk (exr_decode_pipeline_t* decode)
decode->unpacked_alloc_size == 0)
decode->unpacked_buffer = NULL;

if (part->storage_mode == EXR_STORAGE_DEEP_SCANLINE ||
part->storage_mode == EXR_STORAGE_DEEP_TILED)
if ((part->storage_mode == EXR_STORAGE_DEEP_SCANLINE ||
part->storage_mode == EXR_STORAGE_DEEP_TILED) &&
decode->chunk.sample_count_table_size > 0)
{
rv = internal_decode_alloc_buffer (
decode,
Expand Down Expand Up @@ -192,7 +193,7 @@ default_read_chunk (exr_decode_pipeline_t* decode)
decode->packed_sample_count_table);
}
}
else
else if (decode->chunk.packed_size > 0)
{
rv = internal_decode_alloc_buffer (
decode,
Expand All @@ -204,6 +205,8 @@ default_read_chunk (exr_decode_pipeline_t* decode)
rv = exr_read_chunk (
ctxt, decode->part_index, &(decode->chunk), decode->packed_buffer);
}
else
rv = EXR_ERR_SUCCESS;

return rv;
}
Expand Down Expand Up @@ -310,6 +313,13 @@ exr_decoding_initialize (
}
}

/* will have already been reported during header parse, but just
* stop the file from being read
*/
if (!part->channels || part->channels->type != EXR_ATTR_CHLIST ||
part->channels->chlist->num_channels <= 0)
return EXR_ERR_INVALID_ATTR;

rv = internal_coding_fill_channel_info (
&(decode->channels),
&(decode->channel_count),
Expand Down
Loading
Loading