[Forensics-changes] [yara] 13/368: Re-format hex_grammar.y

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.5.0
in repository yara.

commit fb329f607b0a657d17b58225776a3e68e9be2a97
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Wed Jul 1 13:55:28 2015 +0200

    Re-format hex_grammar.y
---
 libyara/hex_grammar.c | 306 +++++++++++++++++++++----------------------
 libyara/hex_grammar.y | 352 +++++++++++++++++++++++++-------------------------
 2 files changed, 332 insertions(+), 326 deletions(-)

diff --git a/libyara/hex_grammar.c b/libyara/hex_grammar.c
index f8b1016..0f7c42c 100644
--- a/libyara/hex_grammar.c
+++ b/libyara/hex_grammar.c
@@ -451,8 +451,8 @@ static const yytype_int8 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,    83,    83,    91,    95,   122,   127,   126,   135,   143,
-     172,   210,   238,   263,   267,   280,   288
+       0,    84,    84,    93,    97,   125,   130,   129,   138,   147,
+     176,   214,   242,   268,   272,   286,   294
 };
 #endif
 
@@ -1401,259 +1401,259 @@ yyreduce:
   switch (yyn)
     {
         case 2:
-#line 84 "hex_grammar.y"
+#line 85 "hex_grammar.y"
     {
-                RE* re = yyget_extra(yyscanner);
-                re->root_node = (yyvsp[(2) - (3)].re_node);
-              }
+        RE* re = yyget_extra(yyscanner);
+        re->root_node = (yyvsp[(2) - (3)].re_node);
+      }
     break;
 
   case 3:
-#line 92 "hex_grammar.y"
+#line 94 "hex_grammar.y"
     {
-            (yyval.re_node) = (yyvsp[(1) - (1)].re_node);
-         }
+        (yyval.re_node) = (yyvsp[(1) - (1)].re_node);
+      }
     break;
 
   case 4:
-#line 96 "hex_grammar.y"
+#line 98 "hex_grammar.y"
     {
-            lex_env->token_count++;
+        lex_env->token_count++;
 
-            if (lex_env->token_count >= MAX_HEX_STRING_TOKENS)
-            {
-              yr_re_node_destroy((yyvsp[(1) - (2)].re_node));
-              yr_re_node_destroy((yyvsp[(2) - (2)].re_node));
+        if (lex_env->token_count >= MAX_HEX_STRING_TOKENS)
+        {
+          yr_re_node_destroy((yyvsp[(1) - (2)].re_node));
+          yr_re_node_destroy((yyvsp[(2) - (2)].re_node));
 
-              yyerror(yyscanner, lex_env, "string too long");
+          yyerror(yyscanner, lex_env, "string too long");
 
-              YYABORT;
-            }
+          YYABORT;
+        }
 
-            DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(1) - (2)].re_node));
-            DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(2) - (2)].re_node));
+        DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(1) - (2)].re_node));
+        DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(2) - (2)].re_node));
 
-            (yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT, (yyvsp[(1) - (2)].re_node), (yyvsp[(2) - (2)].re_node));
+        (yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT, (yyvsp[(1) - (2)].re_node), (yyvsp[(2) - (2)].re_node));
 
-            DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(1) - (2)].re_node));
-            DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(2) - (2)].re_node));
+        DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(1) - (2)].re_node));
+        DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(2) - (2)].re_node));
 
-            ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
-         }
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+      }
     break;
 
   case 5:
-#line 123 "hex_grammar.y"
+#line 126 "hex_grammar.y"
     {
-          (yyval.re_node) = (yyvsp[(1) - (1)].re_node);
-        }
+        (yyval.re_node) = (yyvsp[(1) - (1)].re_node);
+      }
     break;
 
   case 6:
-#line 127 "hex_grammar.y"
+#line 130 "hex_grammar.y"
     {
-          lex_env->inside_or++;
-        }
+        lex_env->inside_or++;
+      }
     break;
 
   case 7:
-#line 131 "hex_grammar.y"
+#line 134 "hex_grammar.y"
     {
-          (yyval.re_node) = (yyvsp[(3) - (4)].re_node);
-          lex_env->inside_or--;
-        }
+        (yyval.re_node) = (yyvsp[(3) - (4)].re_node);
+        lex_env->inside_or--;
+      }
     break;
 
   case 8:
-#line 136 "hex_grammar.y"
+#line 139 "hex_grammar.y"
     {
-          (yyval.re_node) = (yyvsp[(2) - (3)].re_node);
-          (yyval.re_node)->greedy = FALSE;
-        }
+        (yyval.re_node) = (yyvsp[(2) - (3)].re_node);
+        (yyval.re_node)->greedy = FALSE;
+      }
     break;
 
   case 9:
-#line 144 "hex_grammar.y"
+#line 148 "hex_grammar.y"
     {
-          RE_NODE* re_any;
+        RE_NODE* re_any;
 
-          if ((yyvsp[(1) - (1)].integer) < 0)
-          {
-            yyerror(yyscanner, lex_env, "invalid negative jump length");
-            YYABORT;
-          }
+        if ((yyvsp[(1) - (1)].integer) < 0)
+        {
+          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          YYABORT;
+        }
 
-          if (lex_env->inside_or && (yyvsp[(1) - (1)].integer) > STRING_CHAINING_THRESHOLD)
-          {
-            yyerror(yyscanner, lex_env, "jumps over "
-                STR(STRING_CHAINING_THRESHOLD)
-                " now allowed inside alternation (|)");
-            YYABORT;
-          }
+        if (lex_env->inside_or && (yyvsp[(1) - (1)].integer) > STRING_CHAINING_THRESHOLD)
+        {
+          yyerror(yyscanner, lex_env, "jumps over "
+              STR(STRING_CHAINING_THRESHOLD)
+              " now allowed inside alternation (|)");
+          YYABORT;
+        }
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node)->start = (yyvsp[(1) - (1)].integer);
-          (yyval.re_node)->end = (yyvsp[(1) - (1)].integer);
-        }
+        (yyval.re_node)->start = (yyvsp[(1) - (1)].integer);
+        (yyval.re_node)->end = (yyvsp[(1) - (1)].integer);
+      }
     break;
 
   case 10:
-#line 173 "hex_grammar.y"
+#line 177 "hex_grammar.y"
     {
-          RE_NODE* re_any;
+        RE_NODE* re_any;
 
-          if (lex_env->inside_or &&
-              ((yyvsp[(1) - (3)].integer) > STRING_CHAINING_THRESHOLD ||
-               (yyvsp[(3) - (3)].integer) > STRING_CHAINING_THRESHOLD) )
-          {
-            yyerror(yyscanner, lex_env, "jumps over "
-                STR(STRING_CHAINING_THRESHOLD)
-                " now allowed inside alternation (|)");
+        if (lex_env->inside_or &&
+            ((yyvsp[(1) - (3)].integer) > STRING_CHAINING_THRESHOLD ||
+             (yyvsp[(3) - (3)].integer) > STRING_CHAINING_THRESHOLD) )
+        {
+          yyerror(yyscanner, lex_env, "jumps over "
+              STR(STRING_CHAINING_THRESHOLD)
+              " now allowed inside alternation (|)");
 
-            YYABORT;
-          }
+          YYABORT;
+        }
 
-          if ((yyvsp[(1) - (3)].integer) < 0 || (yyvsp[(3) - (3)].integer) < 0)
-          {
-            yyerror(yyscanner, lex_env, "invalid negative jump length");
-            YYABORT;
-          }
+        if ((yyvsp[(1) - (3)].integer) < 0 || (yyvsp[(3) - (3)].integer) < 0)
+        {
+          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          YYABORT;
+        }
 
-          if ((yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer))
-          {
-            yyerror(yyscanner, lex_env, "invalid jump range");
-            YYABORT;
-          }
+        if ((yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer))
+        {
+          yyerror(yyscanner, lex_env, "invalid jump range");
+          YYABORT;
+        }
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node)->start = (yyvsp[(1) - (3)].integer);
-          (yyval.re_node)->end = (yyvsp[(3) - (3)].integer);
-        }
+        (yyval.re_node)->start = (yyvsp[(1) - (3)].integer);
+        (yyval.re_node)->end = (yyvsp[(3) - (3)].integer);
+      }
     break;
 
   case 11:
-#line 211 "hex_grammar.y"
+#line 215 "hex_grammar.y"
     {
-          RE_NODE* re_any;
+        RE_NODE* re_any;
 
-          if (lex_env->inside_or)
-          {
-            yyerror(yyscanner, lex_env,
-                "unbounded jumps not allowed inside alternation (|)");
-            YYABORT;
-          }
+        if (lex_env->inside_or)
+        {
+          yyerror(yyscanner, lex_env,
+              "unbounded jumps not allowed inside alternation (|)");
+          YYABORT;
+        }
 
-          if ((yyvsp[(1) - (2)].integer) < 0)
-          {
-            yyerror(yyscanner, lex_env, "invalid negative jump length");
-            YYABORT;
-          }
+        if ((yyvsp[(1) - (2)].integer) < 0)
+        {
+          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          YYABORT;
+        }
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node)->start = (yyvsp[(1) - (2)].integer);
-          (yyval.re_node)->end = INT_MAX;
-        }
+        (yyval.re_node)->start = (yyvsp[(1) - (2)].integer);
+        (yyval.re_node)->end = INT_MAX;
+      }
     break;
 
   case 12:
-#line 239 "hex_grammar.y"
+#line 243 "hex_grammar.y"
     {
-          RE_NODE* re_any;
+        RE_NODE* re_any;
 
-          if (lex_env->inside_or)
-          {
-            yyerror(yyscanner, lex_env,
-                "unbounded jumps not allowed inside alternation (|)");
-            YYABORT;
-          }
+        if (lex_env->inside_or)
+        {
+          yyerror(yyscanner, lex_env,
+              "unbounded jumps not allowed inside alternation (|)");
+          YYABORT;
+        }
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node)->start = 0;
-          (yyval.re_node)->end = INT_MAX;
-        }
+        (yyval.re_node)->start = 0;
+        (yyval.re_node)->end = INT_MAX;
+      }
     break;
 
   case 13:
-#line 264 "hex_grammar.y"
+#line 269 "hex_grammar.y"
     {
-                  (yyval.re_node) = (yyvsp[(1) - (1)].re_node);
-               }
+          (yyval.re_node) = (yyvsp[(1) - (1)].re_node);
+      }
     break;
 
   case 14:
-#line 268 "hex_grammar.y"
+#line 273 "hex_grammar.y"
     {
-                  mark_as_not_fast_hex_regexp();
+        mark_as_not_fast_hex_regexp();
 
-                  (yyval.re_node) = yr_re_node_create(RE_NODE_ALT, (yyvsp[(1) - (3)].re_node), (yyvsp[(3) - (3)].re_node));
+        (yyval.re_node) = yr_re_node_create(RE_NODE_ALT, (yyvsp[(1) - (3)].re_node), (yyvsp[(3) - (3)].re_node));
 
-                  DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(1) - (3)].re_node));
-                  DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(3) - (3)].re_node));
+        DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(1) - (3)].re_node));
+        DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[(3) - (3)].re_node));
 
-                  ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
-               }
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+      }
     break;
 
   case 15:
-#line 281 "hex_grammar.y"
+#line 287 "hex_grammar.y"
     {
-          (yyval.re_node) = yr_re_node_create(RE_NODE_LITERAL, NULL, NULL);
+        (yyval.re_node) = yr_re_node_create(RE_NODE_LITERAL, NULL, NULL);
 
-          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          (yyval.re_node)->value = (yyvsp[(1) - (1)].integer);
-        }
+        (yyval.re_node)->value = (yyvsp[(1) - (1)].integer);
+      }
     break;
 
   case 16:
-#line 289 "hex_grammar.y"
+#line 295 "hex_grammar.y"
     {
-          uint8_t mask = (yyvsp[(1) - (1)].integer) >> 8;
+        uint8_t mask = (yyvsp[(1) - (1)].integer) >> 8;
 
-          if (mask == 0x00)
-          {
-            (yyval.re_node) = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        if (mask == 0x00)
+        {
+          (yyval.re_node) = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-            ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
-          }
-          else
-          {
-            (yyval.re_node) = yr_re_node_create(RE_NODE_MASKED_LITERAL, NULL, NULL);
+          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+        }
+        else
+        {
+          (yyval.re_node) = yr_re_node_create(RE_NODE_MASKED_LITERAL, NULL, NULL);
 
-            ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+          ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-            (yyval.re_node)->value = (yyvsp[(1) - (1)].integer) & 0xFF;
-            (yyval.re_node)->mask = mask;
-          }
+          (yyval.re_node)->value = (yyvsp[(1) - (1)].integer) & 0xFF;
+          (yyval.re_node)->mask = mask;
         }
+      }
     break;
 
 
@@ -1872,6 +1872,6 @@ yyreturn:
 }
 
 
-#line 310 "hex_grammar.y"
+#line 316 "hex_grammar.y"
 
 
diff --git a/libyara/hex_grammar.y b/libyara/hex_grammar.y
index 810554b..2de254e 100644
--- a/libyara/hex_grammar.y
+++ b/libyara/hex_grammar.y
@@ -80,231 +80,237 @@ limitations under the License.
 
 %%
 
-hex_string : '{' tokens '}'
-              {
-                RE* re = yyget_extra(yyscanner);
-                re->root_node = $2;
-              }
-           ;
-
+hex_string
+    : '{' tokens '}'
+      {
+        RE* re = yyget_extra(yyscanner);
+        re->root_node = $2;
+      }
+    ;
+
+
+tokens
+    : token
+      {
+        $$ = $1;
+      }
+    | tokens token
+      {
+        lex_env->token_count++;
+
+        if (lex_env->token_count >= MAX_HEX_STRING_TOKENS)
+        {
+          yr_re_node_destroy($1);
+          yr_re_node_destroy($2);
 
-tokens : token
-         {
-            $$ = $1;
-         }
-       | tokens token
-         {
-            lex_env->token_count++;
+          yyerror(yyscanner, lex_env, "string too long");
 
-            if (lex_env->token_count >= MAX_HEX_STRING_TOKENS)
-            {
-              yr_re_node_destroy($1);
-              yr_re_node_destroy($2);
+          YYABORT;
+        }
 
-              yyerror(yyscanner, lex_env, "string too long");
+        DESTROY_NODE_IF($$ == NULL, $1);
+        DESTROY_NODE_IF($$ == NULL, $2);
+
+        $$ = yr_re_node_create(RE_NODE_CONCAT, $1, $2);
+
+        DESTROY_NODE_IF($$ == NULL, $1);
+        DESTROY_NODE_IF($$ == NULL, $2);
+
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+      }
+    ;
+
+
+token
+    : byte
+      {
+        $$ = $1;
+      }
+    | '('
+      {
+        lex_env->inside_or++;
+      }
+      alternatives ')'
+      {
+        $$ = $3;
+        lex_env->inside_or--;
+      }
+    | '[' range ']'
+      {
+        $$ = $2;
+        $$->greedy = FALSE;
+      }
+    ;
+
+
+range
+    : _NUMBER_
+      {
+        RE_NODE* re_any;
+
+        if ($1 < 0)
+        {
+          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          YYABORT;
+        }
 
-              YYABORT;
-            }
+        if (lex_env->inside_or && $1 > STRING_CHAINING_THRESHOLD)
+        {
+          yyerror(yyscanner, lex_env, "jumps over "
+              STR(STRING_CHAINING_THRESHOLD)
+              " now allowed inside alternation (|)");
+          YYABORT;
+        }
 
-            DESTROY_NODE_IF($$ == NULL, $1);
-            DESTROY_NODE_IF($$ == NULL, $2);
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-            $$ = yr_re_node_create(RE_NODE_CONCAT, $1, $2);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-            DESTROY_NODE_IF($$ == NULL, $1);
-            DESTROY_NODE_IF($$ == NULL, $2);
+        $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-            ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
-         }
-       ;
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
+        $$->start = $1;
+        $$->end = $1;
+      }
+    | _NUMBER_ '-' _NUMBER_
+      {
+        RE_NODE* re_any;
 
-token : byte
+        if (lex_env->inside_or &&
+            ($1 > STRING_CHAINING_THRESHOLD ||
+             $3 > STRING_CHAINING_THRESHOLD) )
         {
-          $$ = $1;
-        }
-      | '('
-        {
-          lex_env->inside_or++;
-        }
-        alternatives ')'
-        {
-          $$ = $3;
-          lex_env->inside_or--;
+          yyerror(yyscanner, lex_env, "jumps over "
+              STR(STRING_CHAINING_THRESHOLD)
+              " now allowed inside alternation (|)");
+
+          YYABORT;
         }
-      | '[' range ']'
+
+        if ($1 < 0 || $3 < 0)
         {
-          $$ = $2;
-          $$->greedy = FALSE;
+          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          YYABORT;
         }
-      ;
 
-
-range : _NUMBER_
+        if ($1 > $3)
         {
-          RE_NODE* re_any;
-
-          if ($1 < 0)
-          {
-            yyerror(yyscanner, lex_env, "invalid negative jump length");
-            YYABORT;
-          }
+          yyerror(yyscanner, lex_env, "invalid jump range");
+          YYABORT;
+        }
 
-          if (lex_env->inside_or && $1 > STRING_CHAINING_THRESHOLD)
-          {
-            yyerror(yyscanner, lex_env, "jumps over "
-                STR(STRING_CHAINING_THRESHOLD)
-                " now allowed inside alternation (|)");
-            YYABORT;
-          }
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+        $$->start = $1;
+        $$->end = $3;
+      }
+    | _NUMBER_ '-'
+      {
+        RE_NODE* re_any;
 
-          $$->start = $1;
-          $$->end = $1;
-        }
-      | _NUMBER_ '-' _NUMBER_
+        if (lex_env->inside_or)
         {
-          RE_NODE* re_any;
-
-          if (lex_env->inside_or &&
-              ($1 > STRING_CHAINING_THRESHOLD ||
-               $3 > STRING_CHAINING_THRESHOLD) )
-          {
-            yyerror(yyscanner, lex_env, "jumps over "
-                STR(STRING_CHAINING_THRESHOLD)
-                " now allowed inside alternation (|)");
-
-            YYABORT;
-          }
+          yyerror(yyscanner, lex_env,
+              "unbounded jumps not allowed inside alternation (|)");
+          YYABORT;
+        }
 
-          if ($1 < 0 || $3 < 0)
-          {
-            yyerror(yyscanner, lex_env, "invalid negative jump length");
-            YYABORT;
-          }
+        if ($1 < 0)
+        {
+          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          YYABORT;
+        }
 
-          if ($1 > $3)
-          {
-            yyerror(yyscanner, lex_env, "invalid jump range");
-            YYABORT;
-          }
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+        $$->start = $1;
+        $$->end = INT_MAX;
+      }
+    | '-'
+      {
+        RE_NODE* re_any;
 
-          $$->start = $1;
-          $$->end = $3;
-        }
-      | _NUMBER_ '-'
+        if (lex_env->inside_or)
         {
-          RE_NODE* re_any;
-
-          if (lex_env->inside_or)
-          {
-            yyerror(yyscanner, lex_env,
-                "unbounded jumps not allowed inside alternation (|)");
-            YYABORT;
-          }
-
-          if ($1 < 0)
-          {
-            yyerror(yyscanner, lex_env, "invalid negative jump length");
-            YYABORT;
-          }
+          yyerror(yyscanner, lex_env,
+              "unbounded jumps not allowed inside alternation (|)");
+          YYABORT;
+        }
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+        re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
+        $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
 
-          ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-          $$->start = $1;
-          $$->end = INT_MAX;
-        }
-      | '-'
-        {
-          RE_NODE* re_any;
+        $$->start = 0;
+        $$->end = INT_MAX;
+      }
+    ;
 
-          if (lex_env->inside_or)
-          {
-            yyerror(yyscanner, lex_env,
-                "unbounded jumps not allowed inside alternation (|)");
-            YYABORT;
-          }
 
-          re_any = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
-
-          ERROR_IF(re_any == NULL, ERROR_INSUFICIENT_MEMORY);
-
-          $$ = yr_re_node_create(RE_NODE_RANGE, re_any, NULL);
-
-          ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+alternatives
+    : tokens
+      {
+          $$ = $1;
+      }
+    | alternatives '|' tokens
+      {
+        mark_as_not_fast_hex_regexp();
 
-          $$->start = 0;
-          $$->end = INT_MAX;
-        }
-      ;
+        $$ = yr_re_node_create(RE_NODE_ALT, $1, $3);
 
+        DESTROY_NODE_IF($$ == NULL, $1);
+        DESTROY_NODE_IF($$ == NULL, $3);
 
-alternatives : tokens
-               {
-                  $$ = $1;
-               }
-             | alternatives '|' tokens
-               {
-                  mark_as_not_fast_hex_regexp();
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+      }
+    ;
 
-                  $$ = yr_re_node_create(RE_NODE_ALT, $1, $3);
+byte
+    : _BYTE_
+      {
+        $$ = yr_re_node_create(RE_NODE_LITERAL, NULL, NULL);
 
-                  DESTROY_NODE_IF($$ == NULL, $1);
-                  DESTROY_NODE_IF($$ == NULL, $3);
+        ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-                  ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
-               }
-             ;
+        $$->value = $1;
+      }
+    | _MASKED_BYTE_
+      {
+        uint8_t mask = $1 >> 8;
 
-byte  : _BYTE_
+        if (mask == 0x00)
         {
-          $$ = yr_re_node_create(RE_NODE_LITERAL, NULL, NULL);
+          $$ = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
 
           ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
-
-          $$->value = $1;
         }
-      | _MASKED_BYTE_
+        else
         {
-          uint8_t mask = $1 >> 8;
-
-          if (mask == 0x00)
-          {
-            $$ = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+          $$ = yr_re_node_create(RE_NODE_MASKED_LITERAL, NULL, NULL);
 
-            ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
-          }
-          else
-          {
-            $$ = yr_re_node_create(RE_NODE_MASKED_LITERAL, NULL, NULL);
-
-            ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+          ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-            $$->value = $1 & 0xFF;
-            $$->mask = mask;
-          }
+          $$->value = $1 & 0xFF;
+          $$->mask = mask;
         }
-      ;
+      }
+    ;
 
 %%

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list