Skip to content

Commit 3f496bd

Browse files
authored
Merge pull request #2191 from Exiv2/main_fix2190
Detect integer-overflow and throw in that case
2 parents 3ee193f + 3795e53 commit 3f496bd

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

src/exif.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "config.h"
1515
#include "error.hpp"
1616
#include "metadatum.hpp"
17+
#include "safe_op.hpp"
1718
#include "tags.hpp"
1819
#include "tags_int.hpp"
1920
#include "tiffcomposite_int.hpp" // for Tag::root
@@ -741,7 +742,7 @@ Exiv2::DataBuf JpegThumbnail::copy(const Exiv2::ExifData& exifData) const {
741742
int64_t sumToLong(const Exiv2::Exifdatum& md) {
742743
int64_t sum = 0;
743744
for (size_t i = 0; i < md.count(); ++i) {
744-
sum += md.toInt64(i);
745+
sum = Safe::add(sum, md.toInt64(i));
745746
}
746747
return sum;
747748
}

test/data/issue_2190_poc.jp2

2.62 KB
Binary file not shown.

tests/regression_tests/test_regression_allfiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def get_valid_files(data_dir):
5454
"issue_ghsa_8949_hhfh_j7rj_poc.exv",
5555
"exiv2-bug495.jpg",
5656
"issue_1920_poc.tiff",
57+
"issue_2190_poc.jp2",
5758
# non-zero return code files, most of them are security POC so we don't
5859
# really need to worry about them here
5960
"2018-01-09-exiv2-crash-001.tiff",

0 commit comments

Comments
 (0)