Skip to content

Commit

Permalink
read.c: Return BMFF_PARSE_FAILED on unknown top level size 0 box
Browse files Browse the repository at this point in the history
Do not return TRUNCATED_DATA In that case since all the other
similar error paths in that function return BMFF_PARSE_FAILED.

Also, in some cases TRUNCATED_DATA could be considered a
recoverable error but in this case it is not.
  • Loading branch information
vigneshvg committed Apr 30, 2024
1 parent 2f45ea4 commit 4ed0293
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4009,7 +4009,7 @@ static avifResult avifParse(avifDecoder * decoder)
} else if (header.size == 0) {
// An unknown top level box with size 0 was found. If we reach here it means we haven't completed parsing successfully
// since there are no further boxes left.
return AVIF_RESULT_TRUNCATED_DATA;
return AVIF_RESULT_BMFF_PARSE_FAILED;
}
parseOffset += header.size;

Expand Down
2 changes: 1 addition & 1 deletion tests/gtest/avifsize0test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST(AvifDecodeTest, UnknownTopLevelBoxSize0) {
ASSERT_EQ(
avifDecoderSetIOMemory(decoder.get(), avif_edited.data, avif_edited.size),
AVIF_RESULT_OK);
ASSERT_EQ(avifDecoderParse(decoder.get()), AVIF_RESULT_TRUNCATED_DATA);
ASSERT_EQ(avifDecoderParse(decoder.get()), AVIF_RESULT_BMFF_PARSE_FAILED);
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 4ed0293

Please sign in to comment.