Skip to content
Draft
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: 2 additions & 2 deletions av2/decoder/obu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,11 +1320,11 @@ static size_t read_metadata_unit_header(AV2Decoder *pbi, const uint8_t *data,
AV2_COMMON *const cm = &pbi->common;
size_t type_length;
uint64_t type_value;
if (avm_uleb_decode(data, sz, &type_value, &type_length) < 0 ||
type_value > UINT32_MAX) {
if (avm_uleb_decode(data, sz, &type_value, &type_length) < 0) {
cm->error.error_code = AVM_CODEC_CORRUPT_FRAME;
return 0;
}
assert(type_value <= UINT32_MAX);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following code in avm_uleb_decode() ensures that type_value <= UINT32_MAX:

int avm_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value,
                    size_t *length) {
        ...

        // Fail on values larger than 32-bits to ensure consistent behavior on
        // 32 and 64 bit targets: value is typically used to determine buffer
        // allocation size.
        if (*value > UINT32_MAX) return -1;

        ...
}

metadata->type = (uint32_t)type_value;
size_t bytes_read = type_length;

Expand Down