From dca19b60efcdd2f5e7c22e830082242fcc7d262a Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 19 Jan 2014 16:39:46 +0100 Subject: m_alias Fix out of bounds string access that happened with certain replace strings --- src/modules/m_alias.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 25f071bab..32fc80b64 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -320,11 +320,11 @@ class ModuleAlias : public Module for (unsigned int i = 0; i < newline.length(); i++) { char c = newline[i]; - if (c == '$') + if ((c == '$') && (i + 1 < newline.length())) { if (isdigit(newline[i+1])) { - int len = (newline[i+2] == '-') ? 3 : 2; + int len = ((i + 2 < newline.length()) && (newline[i+2] == '-')) ? 3 : 2; std::string var = newline.substr(i, len); result.append(GetVar(var, original_line)); i += len - 1; -- cgit v1.2.3