blob: 45451442d5f10ccdaa5364ef461bbe8252760a10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp
index 29311fd..c0d9553 100644
--- a/src/crwimage_int.cpp
+++ b/src/crwimage_int.cpp
@@ -268,6 +268,9 @@ namespace Exiv2 {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Reading directory 0x" << std::hex << tag() << "\n";
#endif
+ if (this->offset() + this->size() > size)
+ throw Error(kerOffsetOutOfRange);
+
readDirectory(pData + offset(), this->size(), byteOrder);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "<---- 0x" << std::hex << tag() << "\n";
diff --git a/test/data/POC-file_issue_1019 b/test/data/POC-file_issue_1019
new file mode 100755
index 0000000..e69de29
diff --git a/tests/bugfixes/github/test_issue_1019.py b/tests/bugfixes/github/test_issue_1019.py
new file mode 100644
index 0000000..c2682f9
--- /dev/null
+++ b/tests/bugfixes/github/test_issue_1019.py
@@ -0,0 +1,14 @@
+from system_tests import CaseMeta, path
+
+
+class OverreadInCiffDirectoryReadDirectory(metaclass=CaseMeta):
+
+ filename = path("$data_path/POC-file_issue_1019")
+ commands = ["$exiv2 -pv $filename"]
+ stdout = [""]
+ stderr = [
+ """$exiv2_exception_message $filename:
+$kerOffsetOutOfRange
+"""
+ ]
+ retval = [1]
diff --git a/tests/suite.conf b/tests/suite.conf
index 5b31930..dab7427 100644
--- a/tests/suite.conf
+++ b/tests/suite.conf
@@ -19,6 +19,7 @@ largeiptc_test: ${ENV:exiv2_path}/largeiptc-test${ENV:binary_extension}
easyaccess_test: ${ENV:exiv2_path}/easyaccess-test${ENV:binary_extension}
[variables]
+kerOffsetOutOfRange: Offset out of range
kerFailedToReadImageData: Failed to read image data
kerCorruptedMetadata: corrupted image metadata
kerInvalidMalloc: invalid memory allocation request
|