|
|
6ca901 |
From f13ebca839e55d0c7ea1c7f57ae667c47fe9c0d5 Mon Sep 17 00:00:00 2001
|
|
|
6ca901 |
From: Kevin Backhouse <kevinbackhouse@github.com>
|
|
|
6ca901 |
Date: Mon, 5 Jul 2021 10:39:08 +0100
|
|
|
6ca901 |
Subject: [PATCH 1/2] Regression test for
|
|
|
6ca901 |
https://github.com/Exiv2/exiv2/security/advisories/GHSA-583f-w9pm-99r2
|
|
|
6ca901 |
|
|
|
6ca901 |
---
|
|
|
6ca901 |
test/data/issue_ghsa_583f_w9pm_99r2_poc.jp2 | Bin 0 -> 32768 bytes
|
|
|
6ca901 |
.../github/test_issue_ghsa_583f_w9pm_99r2.py | 18 ++++++++++++++++++
|
|
|
6ca901 |
2 files changed, 18 insertions(+)
|
|
|
6ca901 |
create mode 100644 test/data/issue_ghsa_583f_w9pm_99r2_poc.jp2
|
|
|
6ca901 |
create mode 100644 tests/bugfixes/github/test_issue_ghsa_583f_w9pm_99r2.py
|
|
|
6ca901 |
|
|
|
6ca901 |
diff --git a/tests/bugfixes/github/test_issue_ghsa_583f_w9pm_99r2.py b/tests/bugfixes/github/test_issue_ghsa_583f_w9pm_99r2.py
|
|
|
6ca901 |
new file mode 100644
|
|
|
6ca901 |
index 000000000..808916aee
|
|
|
6ca901 |
--- /dev/null
|
|
|
6ca901 |
+++ b/tests/bugfixes/github/test_issue_ghsa_583f_w9pm_99r2.py
|
|
|
6ca901 |
@@ -0,0 +1,18 @@
|
|
|
6ca901 |
+# -*- coding: utf-8 -*-
|
|
|
6ca901 |
+
|
|
|
6ca901 |
+from system_tests import CaseMeta, path, check_no_ASAN_UBSAN_errors
|
|
|
6ca901 |
+
|
|
|
6ca901 |
+class Jp2ImagePrintStructureICC(metaclass=CaseMeta):
|
|
|
6ca901 |
+ """
|
|
|
6ca901 |
+ Regression test for the bug described in:
|
|
|
6ca901 |
+ https://github.com/Exiv2/exiv2/security/advisories/GHSA-583f-w9pm-99r2
|
|
|
6ca901 |
+ """
|
|
|
6ca901 |
+ url = "https://github.com/Exiv2/exiv2/security/advisories/GHSA-583f-w9pm-99r2"
|
|
|
6ca901 |
+
|
|
|
6ca901 |
+ filename = path("$data_path/issue_ghsa_583f_w9pm_99r2_poc.jp2")
|
|
|
6ca901 |
+ commands = ["$exiv2 -p C $filename"]
|
|
|
6ca901 |
+ stdout = [""]
|
|
|
6ca901 |
+ stderr = ["""Exiv2 exception in print action for file $filename:
|
|
|
6ca901 |
+$kerCorruptedMetadata
|
|
|
6ca901 |
+"""]
|
|
|
6ca901 |
+ retval = [1]
|
|
|
6ca901 |
|
|
|
6ca901 |
From dbf472751fc8b87ea7d1de02f54eaf64233a2fb6 Mon Sep 17 00:00:00 2001
|
|
|
6ca901 |
From: Kevin Backhouse <kevinbackhouse@github.com>
|
|
|
6ca901 |
Date: Mon, 5 Jul 2021 10:40:03 +0100
|
|
|
6ca901 |
Subject: [PATCH 2/2] Better bounds checking in Jp2Image::printStructure
|
|
|
6ca901 |
|
|
|
6ca901 |
---
|
|
|
6ca901 |
src/jp2image.cpp | 2 ++
|
|
|
6ca901 |
1 file changed, 2 insertions(+)
|
|
|
6ca901 |
|
|
|
6ca901 |
diff --git a/src/jp2image.cpp b/src/jp2image.cpp
|
|
|
6ca901 |
index 3bf356629..2d6dc2118 100644
|
|
|
6ca901 |
--- a/src/jp2image.cpp
|
|
|
6ca901 |
+++ b/src/jp2image.cpp
|
|
|
6ca901 |
@@ -538,6 +538,7 @@ static void boxes_check(size_t b,size_t m)
|
|
|
6ca901 |
|
|
|
6ca901 |
if (subBox.type == kJp2BoxTypeColorHeader) {
|
|
|
6ca901 |
long pad = 3; // don't know why there are 3 padding bytes
|
|
|
6ca901 |
+ enforce(data.size_ >= pad, kerCorruptedMetadata);
|
|
|
6ca901 |
if (bPrint) {
|
|
|
6ca901 |
out << " | pad:";
|
|
|
6ca901 |
for (int i = 0; i < 3; i++)
|
|
|
6ca901 |
@@ -547,6 +548,7 @@ static void boxes_check(size_t b,size_t m)
|
|
|
6ca901 |
if (bPrint) {
|
|
|
6ca901 |
out << " | iccLength:" << iccLength;
|
|
|
6ca901 |
}
|
|
|
6ca901 |
+ enforce(iccLength <= data.size_ - pad, kerCorruptedMetadata);
|
|
|
6ca901 |
if (bICC) {
|
|
|
6ca901 |
out.write((const char*)data.pData_ + pad, iccLength);
|
|
|
6ca901 |
}
|