Skip to content

Commit

Permalink
Added test for offset in datablock that points outside the datablock.
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSchipperijn committed Nov 23, 2021
1 parent f12b850 commit d908268
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libcoda/coda-cdf-cursor.c
Expand Up @@ -425,8 +425,13 @@ static int read_basic_type(const coda_cursor *cursor, void *dst, long size_bound
{
value_size = size_boundary;
}
if (variable->data != NULL)
if ((variable->data != NULL) && (value_size > 0))
{
if (offset > (variable->num_records * variable->num_values_per_record * variable->value_size))
{
coda_set_error(CODA_ERROR_UNSUPPORTED_PRODUCT, "Offset too large in accessing data of CDF variable");
return -1;
}
memcpy(dst, &variable->data[offset], value_size);
}
else
Expand Down

0 comments on commit d908268

Please sign in to comment.