-
Notifications
You must be signed in to change notification settings - Fork 288
Reject unsupported external iloc data references #3206
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| // Copyright 2024 Google LLC | ||
| // SPDX-License-Identifier: BSD-2-Clause | ||
|
|
||
| #include <algorithm> | ||
| #include <string> | ||
|
|
||
| #include "avif/avif.h" | ||
| #include "aviftest_helpers.h" | ||
| #include "gtest/gtest.h" | ||
|
|
@@ -30,6 +33,35 @@ TEST(IlocTest, TwoExtents) { | |
| EXPECT_LT(psnr, 45.0); | ||
| } | ||
|
|
||
| TEST(IlocTest, NonZeroDataReferenceIndex) { | ||
| testutil::AvifRwData avif = | ||
| testutil::ReadFile(std::string(data_path) + "white_1x1.avif"); | ||
| ASSERT_NE(avif.data, nullptr); | ||
|
|
||
| const uint8_t kIloc[] = {'i', 'l', 'o', 'c'}; | ||
| uint8_t* iloc_position = | ||
| std::search(avif.data, avif.data + avif.size, kIloc, kIloc + 4); | ||
| ASSERT_NE(iloc_position, avif.data + avif.size); | ||
| ASSERT_GE(static_cast<size_t>(avif.data + avif.size - iloc_position), | ||
| size_t{16}); | ||
|
|
||
| // white_1x1.avif uses iloc version 0 with a single item. The | ||
| // data_reference_index field follows the item_ID field. | ||
| ASSERT_EQ(iloc_position[4], 0); | ||
| ASSERT_EQ(iloc_position[10], 0); | ||
| ASSERT_EQ(iloc_position[11], 1); | ||
| ASSERT_EQ(iloc_position[14], 0); | ||
| ASSERT_EQ(iloc_position[15], 0); | ||
| iloc_position[14] = 0; | ||
| iloc_position[15] = 1; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest also verifying
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I verified the fixture layout and added assertions checking the original data_reference_index value before mutating it. |
||
|
|
||
| DecoderPtr decoder(avifDecoderCreate()); | ||
| ASSERT_NE(decoder, nullptr); | ||
| ASSERT_EQ(avifDecoderSetIOMemory(decoder.get(), avif.data, avif.size), | ||
| AVIF_RESULT_OK); | ||
| EXPECT_EQ(avifDecoderParse(decoder.get()), AVIF_RESULT_BMFF_PARSE_FAILED); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
|
|
||
| } // namespace | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the pull request. ISO/IEC 14496-12:2022 Clause 8.11.3 (Item location box) does not require or recommend that
data_reference_indexbe set to 0 when this field is not used. Therefore I think it is better to simply ignore this field.Note that the value 0 is a valid value for
data_reference_index, so one can argue that the value 0 can't really be used to indicate that the field is not used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a closer look. I think the condition at line 2057 should also check that
construction_methodis equal to 0:But it is not clear what value
constructionMethodshould be set to for version 0. Do you know?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a closer look.
From what I understand,
construction_methodis only explicitly present starting fromilocversion 1/2, so for version 0 I’m not fully sure what the intended interpretation should be either.I’ve updated the test to make the fixture assumptions explicit before mutating
data_reference_index.