Skip to content

Commit bf151a1

Browse files
Don't allow zero width/height in WebPImage::inject_VP8X
1 parent 175e609 commit bf151a1

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/webpimage.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,14 @@ void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_
752752
}
753753

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

760761
/* set height - stored in 24bits */
762+
enforce(width > 0, Exiv2::ErrorCode::kerCorruptedMetadata);
761763
uint32_t h = height - 1;
762764
data[7] = h & 0xFF;
763765
data[8] = (h >> 8) & 0xFF;

test/data/issue_2270_poc.webp

114 Bytes
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from system_tests import CaseMeta, CopyTmpFiles, path
4+
@CopyTmpFiles("$data_path/issue_2270_poc.webp")
5+
6+
class WebPImage_inject_VP8X_integer_overflow(metaclass=CaseMeta):
7+
"""
8+
Regression test for the bug described in:
9+
https://github.com/Exiv2/exiv2/issues/2270
10+
"""
11+
url = "https://github.com/Exiv2/exiv2/issues/2270"
12+
13+
filename = path("$tmp_path/issue_2270_poc.webp")
14+
commands = ["$exiv2 rm $filename"]
15+
stdout = [""]
16+
stderr = [
17+
"""$exception_in_erase """ + filename + """:
18+
$kerCorruptedMetadata
19+
"""]
20+
retval = [1]

tests/regression_tests/test_regression_allfiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def get_valid_files(data_dir):
9494
"issue_2160_poc.jpg",
9595
"issue_2178_poc.jp2",
9696
"issue_2268_poc.jp2",
97+
"issue_2270_poc.webp",
9798
"issue_2320_poc.jpg",
9899
"issue_2339_poc.tiff",
99100
"issue_ghsa_583f_w9pm_99r2_poc.jp2",

0 commit comments

Comments
 (0)