]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
prelim support for /* comments */ in text rules
authorRuss Combs <rucombs@cisco.com>
Wed, 5 Nov 2014 20:04:04 +0000 (15:04 -0500)
committerRuss Combs <rucombs@cisco.com>
Wed, 5 Nov 2014 20:04:04 +0000 (15:04 -0500)
ChangeLog
src/parser/parse_stream.cc
src/service_inspectors/http_inspect/hi_module.cc

index 0ec3913daf87746383cbd7a2c6d2ac0cca9fdd1a..fdee32294ebd85bbeb4121cb39ec49e5822270cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,7 @@
 -- fixed boyer-moore init
 -- removed content extract var cruft
 -- latest from Josh
+-- initial /* comments */ for text rules (needs to ignore \")
 
 126
 -- pulled latest from tom
index 5fd3522eb26b192695635f03db5a08f4de034aed..2e4f33315cc0cd114b0bb1c10c37e16be66f559a 100644 (file)
@@ -111,6 +111,11 @@ static TokenType get_token(
                 comments++;
                 state = 1;
             }
+            else if ( c == '/' )
+            {
+                s = c;
+                state = 10;
+            }
             else if ( c == '[' )
             {
                 s += c;
@@ -234,6 +239,52 @@ static TokenType get_token(
             s += c;
             state = 6;
             break;
+        case 10:  // start of comment?
+            if ( c == '*' )
+            {
+                s.clear();
+                state = 11;
+                break;
+            }
+            keys++;
+            // now as if state == 6
+            if ( esc && c == '\\' )
+            {
+                state = 9;
+            }
+            else if ( isspace(c) || strchr(punct, c) )
+            {
+                prev = c;
+                return TT_LITERAL;
+            }
+            else
+            {
+                s += c;
+                state = 6;
+            }
+            break;
+        case 11:  // /* comment */
+            if ( c == '*' )
+                state = 12;
+            else if ( c == '"' )
+                state = 13;
+            break;
+        case 12:  // end of comment?
+            if ( c == '/' )
+            {
+                comments++;
+                state = 0;
+            }
+            break;
+        case 13:  // quoted string in comment
+            if ( c == '"' )
+                state = 11;
+            else if ( c == '\n' )
+            {
+                ParseWarning("line break in commented string on line %d\n", lines-1);
+                state = 11;
+            }
+            break;
         }
         c = is.get();
         chars++;
index eb70bb79a0847ee08292051ac1040923bc955465..d9fa6f1e8408f711854d656171bbe9ff7f5fa1b8 100644 (file)
@@ -284,6 +284,7 @@ static const Parameter hi_server_params[] =
     { "chunk_length", Parameter::PT_INT, "1:", "500000",
       "alert on chunk lengths greater than specified" },
 
+    // FIXIT-M this is backwards: 0 should mean nothing; -1 all
     { "client_flow_depth", Parameter::PT_INT, "-1:1460", "0",
       "raw request payload to inspect" },