From 15328aaa9ff7ffe4c47138687a25e77e41be15df Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Sat, 19 Mar 2022 18:12:10 +0000 Subject: [PATCH] Credit to OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45291 Use std::round() to handle fractions correctly. --- include/exiv2/value.hpp | 3 ++- test/data/issue_2160_poc.jpg | Bin 0 -> 20 bytes 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 test/data/issue_2160_poc.jpg diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 27690e50..051050ab 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -13,6 +13,7 @@ #include #include #include +#include // ***************************************************************************** // namespace extensions @@ -1251,7 +1252,7 @@ class ValueType : public Value { const auto v = value_.at(n); if (static_cast(std::numeric_limits::min()) <= v && v <= static_cast(std::numeric_limits::max())) { - return static_cast(v); + return static_cast(std::round(v)); } else { return 0; } diff --git a/test/data/issue_2160_poc.jpg b/test/data/issue_2160_poc.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5716ff41cd15aadf653e678b01b34a076b21159f GIT binary patch literal 20 bcmZQzVBpCLP*C9IYUg5LVBp9qFv