From 8f0e74a3bf505256f2569cac51a664fdb324cc63 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 4 Jan 2016 21:03:18 +0100 Subject: [PATCH] opkg_manager: fix invalid match with -foo$ "regex" Signed-off-by: Thilo Graf --- src/gui/opkg_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index c4bca4b99..15a3c20ef 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -365,13 +365,14 @@ bool COPKGManager::badpackage(std::string &s) bool res = false; /* poor man's regex :-) only supported are "^" and "$" */ if (p.substr(patlen, 1) == "$") { /* match at end */ - if (s.rfind(p.substr(0, patlen)) == (s.length() - patlen)) + size_t pos = s.rfind(p.substr(0, patlen)); /* s.len-patlen can be -1 == npos */ + if (pos != string::npos && pos == (s.length() - patlen)) res = true; } else if (p.substr(0, 1) == "^") { /* match at beginning */ if (s.find(p.substr(1)) == 0) res = true; } else { /* match everywhere */ - if (s.find(p) != std::string::npos) + if (s.find(p) != string::npos) res = true; } if (res)