From 9951da5710106a0b858783605b563a663a93f565 Mon Sep 17 00:00:00 2001 From: Owen Clarke Date: Tue, 6 Mar 2012 23:32:24 +1100 Subject: [PATCH] Bug - Added bounds check before call to string::substr to avoid passing a negative start pos. Test rc.t was broken from commit 0ac9a4b because it contains 'report.:b' and legacyCheckForDeprecatedVariables was trying to substr starting from pos 'length() - 12' (-3). --- src/legacy.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/legacy.cpp b/src/legacy.cpp index bcf9c984d..88227ac09 100644 --- a/src/legacy.cpp +++ b/src/legacy.cpp @@ -141,12 +141,14 @@ std::string legacyCheckForDeprecatedVariables () for (it = context.config.begin (); it != context.config.end (); ++it) { // report.*.limit - if (it->first.substr (0, 7) == "report." && + if (it->first.length () > 13 && + it->first.substr (0, 7) == "report." && it->first.substr (it->first.length () - 6) == ".limit") deprecated.push_back (it->first); // report.*.annotaitons - if (it->first.substr (0, 7) == "report." && + if (it->first.length () > 19 && + it->first.substr (0, 7) == "report." && it->first.substr (it->first.length () - 12) == ".annotations") deprecated.push_back (it->first);