X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_antibottler.cpp;h=8d588cf5c8a1d863194e35ba69a66e6a2711af30;hb=1f1258997c2d63eb54c5addece622af37f637a7b;hp=78db8f67c743f7c4070b71a82e3b9bb8f781a4a3;hpb=ec7fc489a14af54738da17a94b162a9606df4756;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index 78db8f67c..8d588cf5c 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -13,6 +13,7 @@ * * --------------------------------------------------- */ +using namespace std; #include "users.h" #include "channels.h" @@ -26,14 +27,14 @@ class ModuleAntiBottler : public Module Server *Srv; public: - ModuleAntiBottler() + ModuleAntiBottler(Server* Me) + : Module::Module(Me) { - Srv = new Server; + Srv = Me; } virtual ~ModuleAntiBottler() { - delete Srv; } virtual Version GetVersion() @@ -41,7 +42,6 @@ class ModuleAntiBottler : public Module return Version(1,0,0,1,VF_VENDOR); } - virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user) { if (inbound) @@ -51,30 +51,38 @@ class ModuleAntiBottler : public Module bool not_bottler = false; if (!strncmp(data,"user ",5)) { - for (int j = 0; j < strlen(data); j++) + for (char* j = data; *j; j++) { - if (data[j] = ':') + if (*j == ':') break; - if (data[j] = '"') + if (*j == '"') { not_bottler = true; } } // Bug Fix (#14) -- FCS - if (!strlen(data)) return; - char *user = strtok(data," "); - if (!strlen(data)) return; + + if (!(data) || !(*data)) + return; + + /* + * slight efficiency fix: strtok() just returns NULL if it has no more + * tokens to return. Plus strlen's here really could have been replaced + * with above pointer voodoo :-). --w00t + */ + strtok(data," "); char *ident = strtok(NULL," "); - if (!strlen(data)) return; char *local = strtok(NULL," "); - if (!strlen(data)) return; char *remote = strtok(NULL," :"); - if (!strlen(data)) return; char *gecos = strtok(NULL,"\r\n"); - for (int j = 0; j < strlen(remote); j++) + + if (!ident || !local || !remote || !gecos) + return; + + for (char* j = remote; *j; j++) { - if (((remote[j] < '0') || (remote[j] > '9')) && (remote[j] != '.')) + if (((*j < '0') || (*j > '9')) && (*j != '.')) { not_bottler = true; } @@ -101,9 +109,9 @@ class ModuleAntiBottlerFactory : public ModuleFactory { } - virtual Module * CreateModule() + virtual Module * CreateModule(Server* Me) { - return new ModuleAntiBottler; + return new ModuleAntiBottler(Me); } };