+/* +------------------------------------+
+ * | 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);
}
if ((mask[I]=='*') && (MWC==0))
{
- strcpy(OldM,mask);
+ strlcpy(OldM,mask,MAXBUF);
Delete(mask,I);
Insert("?",mask,I);
}
- strcpy(mask,OldM);
+ strlcpy(mask,OldM,MAXBUF);
Delete(mask,I);
Insert("?",mask,I);
}
}
-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);
}