[Patchew-devel] [PATCH] search: protect x[-1] with length check

Paolo Bonzini posted 1 patch 19 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180727104332.8259-1-pbonzini@redhat.com
api/search.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

[Patchew-devel] [PATCH] search: protect x[-1] with length check

Posted by Paolo Bonzini 19 weeks ago
Otherwise, "Less than" and "Greater than" symbols in a search query
cause an out-of-range access and a 500 server error.

Reported by Steffen Goertz.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 api/search.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/search.py b/api/search.py
index ba3703c..63ccfaa 100644
--- a/api/search.py
+++ b/api/search.py
@@ -134,7 +134,7 @@ Search text keyword in the email message. Example:
         if term.startswith("age:"):
             cond = term[term.find(":") + 1:]
             q = self._process_age_term(query, cond)
-        elif term[0] in "<>":
+        elif term[0] in "<>" and len(term) > 1:
             q = self._process_age_term(query, term)
         elif term.startswith("from:"):
             cond = term[term.find(":") + 1:]
-- 
2.17.1

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel