From d741ca6c7465768e14ee65015a7e45ae72646994 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 13 Oct 2015 09:38:31 +0200 Subject: [PATCH] Fix parsing performance data labels which contain '=' fixes #10254 --- lib/base/string.hpp | 10 ++++++++++ lib/icinga/perfdatavalue.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/base/string.hpp b/lib/base/string.hpp index d0945be32..5d393f6f9 100644 --- a/lib/base/string.hpp +++ b/lib/base/string.hpp @@ -192,6 +192,16 @@ public: return m_Data.find_first_not_of(ch, pos); } + inline SizeType FindLastOf(const char *s, SizeType pos = NPos) const + { + return m_Data.find_last_of(s, pos); + } + + inline SizeType FindLastOf(char ch, SizeType pos = NPos) const + { + return m_Data.find_last_of(ch, pos); + } + inline String SubStr(SizeType first, SizeType len = NPos) const { return m_Data.substr(first, len); diff --git a/lib/icinga/perfdatavalue.cpp b/lib/icinga/perfdatavalue.cpp index b3e0ae1be..ae8e27f00 100644 --- a/lib/icinga/perfdatavalue.cpp +++ b/lib/icinga/perfdatavalue.cpp @@ -50,7 +50,7 @@ PerfdataValue::PerfdataValue(String label, double value, bool counter, PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata) { - size_t eqp = perfdata.FindFirstOf('='); + size_t eqp = perfdata.FindLastOf('='); if (eqp == String::NPos) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid performance data value: " + perfdata)); -- 2.40.0