small fix for ! inside of content match

remotes/origin/master-1.0.x
William Metcalf 16 years ago committed by Victor Julien
parent 9ec2057a21
commit 811f2f605d

@ -627,20 +627,22 @@ DetectContentData *DetectContentParse (char *contentstr)
free(temp); free(temp);
temp = NULL; temp = NULL;
if (str[0] == '!') { /*This was submitted as a patch for bug #11. But this impliments incorrect behavior as !
if (cd->negated == 1) { *inside of quotes should be treated as normal match. */
SCLogDebug("Invalid negated content. \"!\" located twice at the " //if (str[0] == '!') {
"start of the contet string: %s", contentstr); // if (cd->negated == 1) {
goto error; // SCLogDebug("Invalid negated content. \"!\" located twice at the "
} else { // "start of the contet string: %s", contentstr);
temp = str; // goto error;
if ( (str = strdup(temp + 1)) == NULL) // } else {
goto error; // temp = str;
cd->negated = 1; // if ( (str = strdup(temp + 1)) == NULL)
free(temp); // goto error;
temp = NULL; // cd->negated = 1;
} // free(temp);
} // temp = NULL;
// }
//}
len = strlen(str); len = strlen(str);
if (len == 0) if (len == 0)
@ -2659,7 +2661,7 @@ int DetectContentParseNegTest12(void) {
int DetectContentParseNegTest13(void) { int DetectContentParseNegTest13(void) {
int result = 0; int result = 0;
DetectContentData *cd = NULL; DetectContentData *cd = NULL;
char *teststring = "\"!boo\""; char *teststring = "!\"boo\"";
cd = DetectContentParse(teststring); cd = DetectContentParse(teststring);
if (cd != NULL) { if (cd != NULL) {
@ -2676,7 +2678,7 @@ int DetectContentParseNegTest14(void) {
cd = DetectContentParse(teststring); cd = DetectContentParse(teststring);
if (cd != NULL) { if (cd != NULL) {
result = (cd->negated == 1); result = (cd->negated == 0);
DetectContentFree(cd); DetectContentFree(cd);
} }
return result; return result;
@ -3056,7 +3058,7 @@ static int SigTest74TestNegatedContent(void)
static int SigTest75TestNegatedContent(void) static int SigTest75TestNegatedContent(void)
{ {
return SigTestPositiveTestContent("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"USER\"; content:\"!PASS\"; sid:1;)", (uint8_t *)"USER apple"); return SigTestPositiveTestContent("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"USER\"; content:\"!PASS\"; sid:1;)", (uint8_t *)"USER !PASS");
} }
#endif /* UNITTESTS */ #endif /* UNITTESTS */

Loading…
Cancel
Save