]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/wildcard.cpp
Added getrlimit/setrlimit to set process limits to allow a core dump
[user/henk/code/inspircd.git] / src / wildcard.cpp
index 41070d14506c8f30fdae2f48902a09406760e4c7..123abc500bf85fa81991f9db42458ef67508833b 100644 (file)
@@ -1,21 +1,38 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *                       E-mail:
+ *                <brain@chatspike.net>
+ *               <Craig@chatspike.net>
+ *     
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #include <string>
 #include "inspircd_config.h"
 #include "inspircd.h"
+#include "inspstring.h"
 
 void Delete(char* str,int pos)
 {
        char moo[MAXBUF];
-       strcpy(moo,str);
+       strlcpy(moo,str,MAXBUF);
        moo[pos] = '\0';
-       strcpy(str,moo);
-       strcat(str,moo+pos+1);
+       strlcpy(str,moo,MAXBUF);
+       strlcat(str,moo+pos+1,MAXBUF);
 }
 
 void Insert(char* substr,char* str,int pos)
 {
        std::string a = str;
        a.insert(pos,substr);
-       strcpy(str,a.c_str());
+       strlcpy(str,a.c_str(),MAXBUF);
 }
 
 
@@ -41,7 +58,7 @@ if ((strstr(mask,"*")==0) && (strlen(literal) != strlen(mask)))
  
    if ((mask[I]=='*') && (MWC==0))
    {
-     strcpy(OldM,mask);
+     strlcpy(OldM,mask,MAXBUF);
      
      Delete(mask,I);
      
@@ -53,7 +70,7 @@ if ((strstr(mask,"*")==0) && (strlen(literal) != strlen(mask)))
 
        Insert("?",mask,I);
      }
-     strcpy(mask,OldM);
+     strlcpy(mask,OldM,MAXBUF);
      Delete(mask,I);
      Insert("?",mask,I);
    }
@@ -75,15 +92,24 @@ if ((strstr(mask,"*")==0) && (strlen(literal) != strlen(mask)))
 
 }
 
-bool match(char* literal, char* mask)
+bool match(const char* literal, const char* mask)
 {
        char L[10240];
        char M[10240];
        MWC = 0;
-       strncpy(L,literal,10240);
-       strncpy(M,mask,10240);
+       strlcpy(L,literal,10240);
+       strlcpy(M,mask,10240);
        strlower(L);
        strlower(M);
+       // short circuit literals
+       log(DEBUG,"Match '%s' to '%s'",L,M);
+       if ((!strchr(M,'*')) && (!strchr(M,'?')))
+       {
+               if (!strcasecmp(L,M))
+               {
+                       return true;
+               }
+       }
        match2(L,M);
        return (MWC == 2);
 }