]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
reject mixed relative and non-relative keywords
authorEileen Donlon <emdonlo@gmail.com>
Thu, 26 Jan 2012 18:06:03 +0000 (13:06 -0500)
committerVictor Julien <victor@inliniac.net>
Thu, 8 Mar 2012 13:31:50 +0000 (14:31 +0100)
reject signatures using relative and non-relative positional keywords for the same content (depth or offset with distance or within)

src/detect-depth.c
src/detect-distance.c
src/detect-offset.c
src/detect-within.c

index 8c393a50e84d144887ef0f50f2f90ca5ef475660..e7afbbb397c1772478aeb7dd2a2eea022d302db8 100644 (file)
@@ -136,6 +136,12 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths
                 }
             }
 
+            if (cd->flags & DETECT_CONTENT_WITHIN || cd->flags & DETECT_CONTENT_DISTANCE) {
+                SCLogError(SC_ERR_INVALID_SIGNATURE, "You can't use a relative keyword "
+                               "with a non-relative keyword for the same content." );
+                goto error;
+            }
+
             if (str[0] != '-' && isalpha(str[0])) {
                 SigMatch *bed_sm =
                     DetectByteExtractRetrieveSMVar(str, s,
index 5600bb7a98226c5ac087cdbdd819535d08ebf7fe..37f85b25e7ed38c55f4e4ce123858a490e181e05 100644 (file)
@@ -210,6 +210,12 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
                 }
             }
 
+            if (cd->flags & DETECT_CONTENT_DEPTH || cd->flags & DETECT_CONTENT_OFFSET) {
+                SCLogError(SC_ERR_INVALID_SIGNATURE, "You can't use a relative keyword "
+                               "with a non-relative keyword for the same content." );
+                goto error;
+            }
+
             if (str[0] != '-' && isalpha(str[0])) {
                 SigMatch *bed_sm =
                     DetectByteExtractRetrieveSMVar(str, s,
index dec956b5172e01ae1060fdd1680837cdbfa0d1fe..15c241313eb17c9a64f7994069adf63ba42ad958 100644 (file)
@@ -135,6 +135,12 @@ int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *offsetstr)
                 }
             }
 
+            if (cd->flags & DETECT_CONTENT_WITHIN || cd->flags & DETECT_CONTENT_DISTANCE) {
+                SCLogError(SC_ERR_INVALID_SIGNATURE, "You can't use a relative keyword "
+                               "with a non-relative keyword for the same content." );
+                goto error;
+            }
+
             if (str[0] != '-' && isalpha(str[0])) {
                 SigMatch *bed_sm =
                     DetectByteExtractRetrieveSMVar(str, s,
@@ -163,7 +169,6 @@ int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *offsetstr)
 
             break;
 
-
         default:
             SCLogError(SC_ERR_OFFSET_MISSING_CONTENT, "offset needs a preceeding"
                     " content or uricontent option");
index 525422f46aeccb34f28ef1bae0d6ab63b3bc704b..96a644ccdd71470018a03c86dc71b5c32b391a9e 100644 (file)
@@ -212,6 +212,12 @@ static int DetectWithinSetup (DetectEngineCtx *de_ctx, Signature *s, char *withi
                 }
             }
 
+            if (cd->flags & DETECT_CONTENT_DEPTH || cd->flags & DETECT_CONTENT_OFFSET) {
+                SCLogError(SC_ERR_INVALID_SIGNATURE, "You can't use a relative keyword "
+                               "with a non-relative keyword for the same content." );
+                goto error;
+            }
+
             if (str[0] != '-' && isalpha(str[0])) {
                 SigMatch *bed_sm =
                     DetectByteExtractRetrieveSMVar(str, s,