Skip to content

Commit

Permalink
Merge pull request from GHSA-hrw9-ggg3-3r4r
Browse files Browse the repository at this point in the history
Fix integer overflow in BmffImage::brotliUncompress
  • Loading branch information
kevinbackhouse committed Nov 5, 2023
2 parents 8fd2dfb + d8f82d5 commit e884a09
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bmffimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void BmffImage::brotliUncompress(const byte* compressedBuf, size_t compressedBuf
uncompressedLen *= 2;
// DoS protection - can't be bigger than 128k
if (uncompressedLen > 131072) {
if (++dos > 1)
if (++dos > 1 || total_out > 131072)
break;
uncompressedLen = 131072;
}
Expand Down
Binary file added test/data/issue_ghsa_hrw9_ggg3_3r4r_poc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tests/bugfixes/github/test_issue_ghsa_hrw9_ggg3_3r4r.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-

from system_tests import CaseMeta, path

class BrotliUncompressOutOfBoundsWrite(metaclass=CaseMeta):
"""
Regression test for the bug described in:
https://github.com/Exiv2/exiv2/security/advisories/GHSA-hrw9-ggg3-3r4r
"""
url = "https://github.com/Exiv2/exiv2/security/advisories/GHSA-hrw9-ggg3-3r4r"

filename = path("$data_path/issue_ghsa_hrw9_ggg3_3r4r_poc.jpg")
commands = ["$exiv2 $filename"]
stdout = [""]
stderr = [
"""Exiv2 exception in print action for file $filename:
$kerFailedToReadImageData
"""]
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 @@ -116,6 +116,7 @@ def get_valid_files(data_dir):
"issue_ghsa_583f_w9pm_99r2_poc.jp2",
"issue_ghsa_7569_phvm_vwc2_poc.jp2",
"issue_ghsa_mxw9_qx4c_6m8v_poc.jp2",
"issue_ghsa_hrw9_ggg3_3r4r_poc.jpg",
"pocIssue283.jpg",
"poc_1522.jp2",
"xmpsdk.xmp",
Expand Down

0 comments on commit e884a09

Please sign in to comment.