#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);
}
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);
}