From: Attila Molnar Date: Sun, 19 Jan 2014 15:39:46 +0000 (+0100) Subject: m_alias Fix out of bounds string access that happened with certain replace strings X-Git-Tag: v2.0.23~230 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=dca19b60efcdd2f5e7c22e830082242fcc7d262a;p=user%2Fhenk%2Fcode%2Finspircd.git m_alias Fix out of bounds string access that happened with certain replace strings --- 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;