projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
novi upstream verzije 2.8.3
[ossec-hids.git]
/
src
/
os_regex
/
os_regex_match.c
diff --git
a/src/os_regex/os_regex_match.c
b/src/os_regex/os_regex_match.c
index
8932cff
..
a62bd75
100755
(executable)
--- a/
src/os_regex/os_regex_match.c
+++ b/
src/os_regex/os_regex_match.c
@@
-14,11
+14,13
@@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+
+#include "os_regex.h"
#include "os_regex_internal.h"
/* Algorithm:
* Go as faster as you can :)
#include "os_regex_internal.h"
/* Algorithm:
* Go as faster as you can :)
- *
+ *
* Supports:
* '|' to separate multiple OR patterns
* '^' to match the begining of a string
* Supports:
* '|' to separate multiple OR patterns
* '^' to match the begining of a string
@@
-26,15
+28,15
@@
/** Prototypes **/
/** Prototypes **/
-int _InternalMatch(char *pattern, char *str,int count);
+static int _InternalMatch(const char *pattern, const char *str,size_t count) __attribute__((nonnull));
-/* OS_WordMatch v0.3:
- * Searches for pattern in the string
+/* OS_WordMatch v0.3:
+ * Searches for pattern in the string
*/
*/
-int OS_WordMatch(char *pattern, char *str)
+int OS_WordMatch(const char *pattern, const char *str)
{
{
- int count = 0;
+ size_t count = 0;
if(*pattern == '\0')
return(FALSE);
if(*pattern == '\0')
return(FALSE);
@@
-57,9
+59,9
@@
int OS_WordMatch(char *pattern, char *str)
continue;
}
}
continue;
}
}
-
+
count++;
count++;
-
+
}while(pattern[count] != '\0');
/* Last check until end of string */
}while(pattern[count] != '\0');
/* Last check until end of string */
@@
-67,25
+69,25
@@
int OS_WordMatch(char *pattern, char *str)
}
/* Internal match function */
}
/* Internal match function */
-int _InternalMatch(char *pattern, char *str, int pattern_size)
+static int _InternalMatch(const char *pattern, const char *str, size_t pattern_size)
{
{
- uchar *pt = (uchar *)pattern;
- uchar *st = (uchar *)str;
+ const uchar *pt = (const uchar *)pattern;
+ const uchar *st = (const uchar *)str;
- uchar last_char = pattern[pattern_size];
-
+ const uchar last_char = (const uchar) pattern[pattern_size];
- /* Return true for some odd expressions */
+
+ /* Return true for some odd expressions */
if(*pattern == '\0')
return(TRUE);
if(*pattern == '\0')
return(TRUE);
-
+
/* If '^' specified, just do a strncasecmp */
else if(*pattern == '^')
{
pattern++;
pattern_size --;
/* If '^' specified, just do a strncasecmp */
else if(*pattern == '^')
{
pattern++;
pattern_size --;
-
+
/* Compare two string */
if(strncasecmp(pattern,str,pattern_size) == 0)
return(TRUE);
/* Compare two string */
if(strncasecmp(pattern,str,pattern_size) == 0)
return(TRUE);
@@
-96,37
+98,37
@@
int _InternalMatch(char *pattern, char *str, int pattern_size)
/* Null line */
else if(*st == '\0')
return(FALSE);
/* Null line */
else if(*st == '\0')
return(FALSE);
-
-
+
+
/* Look to match the first pattern */
do
{
/* Match */
if(charmap[*st] == charmap[*pt])
{
/* Look to match the first pattern */
do
{
/* Match */
if(charmap[*st] == charmap[*pt])
{
- str = (char *)st++;
+ str = (const char *)st++;
pt++;
pt++;
-
+
while(*pt != last_char)
{
if(*st == '\0')
return(FALSE);
while(*pt != last_char)
{
if(*st == '\0')
return(FALSE);
-
+
else if(charmap[*pt] != charmap[*st])
goto error;
else if(charmap[*pt] != charmap[*st])
goto error;
-
- st++;pt++;
+
+ st++;pt++;
}
/* Return here if pt == last_char */
return(TRUE);
}
/* Return here if pt == last_char */
return(TRUE);
-
+
error:
error:
- st = (uchar *)str;
- pt = (uchar *)pattern;
-
+ st = (const uchar *)str;
+ pt = (const uchar *)pattern;
+
}
}
-
+
st++;
}while(*st != '\0');
st++;
}while(*st != '\0');