]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_alias Fix out of bounds string access that happened with certain replace strings
authorAttila Molnar <attilamolnar@hush.com>
Sun, 19 Jan 2014 15:39:46 +0000 (16:39 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Sun, 19 Jan 2014 15:39:46 +0000 (16:39 +0100)
src/modules/m_alias.cpp

index 25f071bab3ded04560ae8f7e73f7afc42991d38b..32fc80b64d5427638a4a7919b2d437fa34afdec3 100644 (file)
@@ -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;