Skip to content
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

Don't allow zero width/height in WebPImage::inject_VP8X #2348

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/webpimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,14 @@ void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_
}

/* set width - stored in 24bits*/
enforce(width > 0, Exiv2::ErrorCode::kerCorruptedMetadata);
uint32_t w = width - 1;
data[4] = w & 0xFF;
data[5] = (w >> 8) & 0xFF;
data[6] = (w >> 16) & 0xFF;

/* set height - stored in 24bits */
enforce(width > 0, Exiv2::ErrorCode::kerCorruptedMetadata);
uint32_t h = height - 1;
data[7] = h & 0xFF;
data[8] = (h >> 8) & 0xFF;
Expand Down
Binary file added test/data/issue_2270_poc.webp
Binary file not shown.
20 changes: 20 additions & 0 deletions tests/bugfixes/github/test_issue_2270.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-

from system_tests import CaseMeta, CopyTmpFiles, path
@CopyTmpFiles("$data_path/issue_2270_poc.webp")

class WebPImage_inject_VP8X_integer_overflow(metaclass=CaseMeta):
"""
Regression test for the bug described in:
https://github.com/Exiv2/exiv2/issues/2270
"""
url = "https://github.com/Exiv2/exiv2/issues/2270"

filename = path("$tmp_path/issue_2270_poc.webp")
commands = ["$exiv2 rm $filename"]
stdout = [""]
stderr = [
"""$exception_in_erase """ + filename + """:
$kerCorruptedMetadata
"""]
retval = [1]
1 change: 1 addition & 0 deletions tests/regression_tests/test_regression_allfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def get_valid_files(data_dir):
"issue_2160_poc.jpg",
"issue_2178_poc.jp2",
"issue_2268_poc.jp2",
"issue_2270_poc.webp",
"issue_2320_poc.jpg",
"issue_2339_poc.tiff",
"issue_ghsa_583f_w9pm_99r2_poc.jp2",
Expand Down