-
Notifications
You must be signed in to change notification settings - Fork 287
Validate property allocation size in avifImageCopyProperties() #3226
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 |
|---|---|---|
|
|
@@ -49,5 +49,27 @@ TEST(AvifImageTest, WriteImage) { | |
| image.get(), (testing::TempDir() + "/avifimagetest.png").c_str())); | ||
| } | ||
|
|
||
| TEST(AvifImageTest, CopyRejectsTooManyProperties) { | ||
| ImagePtr src(avifImageCreateEmpty()); | ||
| ImagePtr dst(avifImageCreateEmpty()); | ||
| ASSERT_NE(src, nullptr); | ||
| ASSERT_NE(dst, nullptr); | ||
|
|
||
| const uint8_t property_type[4] = {'a', 'b', 'c', 'd'}; | ||
| const uint8_t property_payload = 0; | ||
| ASSERT_EQ(avifImageAddOpaqueProperty(src.get(), property_type, | ||
| &property_payload, | ||
| sizeof(property_payload)), | ||
| AVIF_RESULT_OK); | ||
|
|
||
| src->numProperties = | ||
| std::numeric_limits<size_t>::max() / sizeof(avifImageItemProperty) + 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. This changes
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. To drive home the necessity of this kind of API contract (whether explicit or implicit), suppose we change this line to the following instead: It will also make |
||
| EXPECT_EQ(avifImageCopy(dst.get(), src.get(), AVIF_PLANES_ALL), | ||
| AVIF_RESULT_INVALID_ARGUMENT); | ||
| src->numProperties = 1; | ||
| EXPECT_EQ(dst->properties, nullptr); | ||
| EXPECT_EQ(dst->numProperties, 0u); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace avif | ||
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.
This check is not necessary. The API contract requires that
srcImagepoints to a validavifImage.