From 9f1e3e3e7273a4c0a94a287432bca0c44c6121c7 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Fri, 17 Sep 2021 22:31:12 +0100 Subject: [PATCH] Credit to OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38887 Fix quadratic loops. --- src/pentaxmn_int.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pentaxmn_int.cpp b/src/pentaxmn_int.cpp index 7c3c1e1360..f4cb3863f8 100644 --- a/src/pentaxmn_int.cpp +++ b/src/pentaxmn_int.cpp @@ -1014,8 +1014,8 @@ namespace Exiv2 { std::ostream& PentaxMakerNote::printVersion(std::ostream& os, const Value& value, const ExifData*) { std::string val = value.toString(); - size_t i; - while ((i = val.find(' ')) != std::string::npos && i != val.length() - 1) { + size_t i = 0; + while ((i = val.find(' ', i)) != std::string::npos && i != val.length() - 1) { val.replace(i, 1, "."); } os << val; @@ -1025,8 +1025,8 @@ namespace Exiv2 { std::ostream& PentaxMakerNote::printResolution(std::ostream& os, const Value& value, const ExifData*) { std::string val = value.toString(); - size_t i; - while ((i = val.find(' ')) != std::string::npos && i != val.length() - 1) { + size_t i = 0; + while ((i = val.find(' ', i)) != std::string::npos && i != val.length() - 1) { val.replace(i, 1, "x"); } os << val;