[Forensics-changes] [yara] 288/415: Fix issue with anchors ^ and $ in regular expressions handled incorrectly

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:15 UTC 2014


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

bengen pushed a commit to branch debian
in repository yara.

commit 09ff1d0dc2611b10a951bdcd9ee3741372c33a9b
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Wed Dec 4 15:46:10 2013 +0100

    Fix issue with anchors ^ and $ in regular expressions handled incorrectly
---
 libyara/atoms.c      |   2 +
 libyara/parser.c     |   6 --
 libyara/re.c         |  30 +++++-
 libyara/re.h         |  23 +++--
 libyara/re_grammar.c | 164 ++++++++++++++++-------------
 libyara/re_grammar.y |  14 +++
 libyara/re_lexer.c   | 283 ++++++++++++++++++++++-----------------------------
 libyara/re_lexer.h   |   1 -
 libyara/re_lexer.l   |  33 ------
 libyara/rules.c      |  19 ----
 libyara/yara.h       |  12 +--
 11 files changed, 272 insertions(+), 315 deletions(-)

diff --git a/libyara/atoms.c b/libyara/atoms.c
index 9cd24af..171a903 100644
--- a/libyara/atoms.c
+++ b/libyara/atoms.c
@@ -757,6 +757,8 @@ ATOM_TREE_NODE* _yr_atoms_extract_from_re_node(
     case RE_NODE_DIGIT:
     case RE_NODE_NON_DIGIT:
     case RE_NODE_EMPTY:
+    case RE_NODE_ANCHOR_START:
+    case RE_NODE_ANCHOR_END:
 
       append_current_leaf_to_node(current_node);
       return current_node;
diff --git a/libyara/parser.c b/libyara/parser.c
index 501906f..4ec5757 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -284,12 +284,6 @@ YR_STRING* yr_parser_reduce_string_declaration(
       goto _exit;
     }
 
-    if (re->flags & RE_FLAGS_START_ANCHORED)
-      string->g_flags |= STRING_GFLAGS_START_ANCHORED;
-
-    if (re->flags & RE_FLAGS_END_ANCHORED)
-      string->g_flags |= STRING_GFLAGS_END_ANCHORED;
-
     if (re->flags & RE_FLAGS_FAST_HEX_REGEXP)
       string->g_flags |= STRING_GFLAGS_FAST_HEX_REGEXP;
 
diff --git a/libyara/re.c b/libyara/re.c
index b267b9c..868a92a 100644
--- a/libyara/re.c
+++ b/libyara/re.c
@@ -514,6 +514,24 @@ int _yr_re_emit(
     *code_size += 32;
     break;
 
+  case RE_NODE_ANCHOR_START:
+
+    FAIL_ON_ERROR(_yr_emit_inst(
+        arena,
+        RE_OPCODE_MATCH_AT_START,
+        &instruction_addr,
+        code_size));
+    break;
+
+  case RE_NODE_ANCHOR_END:
+
+    FAIL_ON_ERROR(_yr_emit_inst(
+        arena,
+        RE_OPCODE_MATCH_AT_END,
+        &instruction_addr,
+        code_size));
+    break;
+
   case RE_NODE_CONCAT:
 
     if (flags & EMIT_FLAGS_BACKWARDS)
@@ -1201,8 +1219,13 @@ int yr_re_exec(
           break;
 
         case RE_OPCODE_MATCH:
+        case RE_OPCODE_MATCH_AT_START:
+        case RE_OPCODE_MATCH_AT_END:
 
-          if (flags & RE_FLAGS_END_ANCHORED && count < input_size)
+          if ((*ip == RE_OPCODE_MATCH_AT_START &&
+               input_size - 1 > count - character_size) ||
+              (*ip == RE_OPCODE_MATCH_AT_END &&
+               input_size > count))
           {
             fiber = _yr_re_fiber_kill(fiber, &fibers, &storage->fiber_pool);
             break;
@@ -1240,10 +1263,9 @@ int yr_re_exec(
     else
       input += character_size;
 
-    count++;
+    count += character_size;
 
-    if ((flags & RE_FLAGS_SCAN) && !(flags & RE_FLAGS_START_ANCHORED) &&
-        count < max_count)
+    if ((flags & RE_FLAGS_SCAN) && count < max_count)
     {
       fiber = _yr_re_fiber_create(&storage->fiber_pool);
       fiber->ip = code;
diff --git a/libyara/re.h b/libyara/re.h
index 6e51048..bbeb5a3 100644
--- a/libyara/re.h
+++ b/libyara/re.h
@@ -35,6 +35,8 @@ limitations under the License.
 #define RE_NODE_DIGIT               14
 #define RE_NODE_NON_DIGIT           15
 #define RE_NODE_EMPTY               16
+#define RE_NODE_ANCHOR_START        17
+#define RE_NODE_ANCHOR_END          18
 
 
 #define RE_OPCODE_ANY               0xA0
@@ -49,6 +51,8 @@ limitations under the License.
 #define RE_OPCODE_DIGIT             0xA9
 #define RE_OPCODE_NON_DIGIT         0xAA
 #define RE_OPCODE_MATCH             0xAB
+#define RE_OPCODE_MATCH_AT_END      0xAC
+#define RE_OPCODE_MATCH_AT_START    0xAD
 
 #define RE_OPCODE_SPLIT_A           0xB0
 #define RE_OPCODE_SPLIT_B           0xB1
@@ -57,17 +61,14 @@ limitations under the License.
 #define RE_OPCODE_JNZ               0xB4
 #define RE_OPCODE_JUMP              0xB5
 
-
-#define RE_FLAGS_START_ANCHORED           0x01
-#define RE_FLAGS_END_ANCHORED             0x02
-#define RE_FLAGS_LITERAL_STRING           0x04
-#define RE_FLAGS_FAST_HEX_REGEXP          0x08
-#define RE_FLAGS_BACKWARDS                0x10
-#define RE_FLAGS_EXHAUSTIVE               0x20
-#define RE_FLAGS_WIDE                     0x40
-#define RE_FLAGS_NO_CASE                  0x80
-#define RE_FLAGS_SCAN                     0x100
-#define RE_FLAGS_DOT_ALL                  0x200
+#define RE_FLAGS_LITERAL_STRING           0x01
+#define RE_FLAGS_FAST_HEX_REGEXP          0x02
+#define RE_FLAGS_BACKWARDS                0x04
+#define RE_FLAGS_EXHAUSTIVE               0x08
+#define RE_FLAGS_WIDE                     0x10
+#define RE_FLAGS_NO_CASE                  0x20
+#define RE_FLAGS_SCAN                     0x40
+#define RE_FLAGS_DOT_ALL                  0x80
 
 
 typedef struct RE RE;
diff --git a/libyara/re_grammar.c b/libyara/re_grammar.c
index bb61fe5..d0dda82 100644
--- a/libyara/re_grammar.c
+++ b/libyara/re_grammar.c
@@ -389,18 +389,18 @@ union yyalloc
 #endif
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  18
+#define YYFINAL  20
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   38
+#define YYLAST   40
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  20
+#define YYNTOKENS  22
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  6
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  26
+#define YYNRULES  28
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  30
+#define YYNSTATES  32
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
@@ -415,13 +415,13 @@ static const yytype_uint8 yytranslate[] =
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-      17,    18,    14,    16,     2,     2,    19,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,    18,     2,     2,     2,
+      19,    20,    14,    16,     2,     2,    21,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,    15,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,    17,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,    13,     2,     2,     2,     2,     2,
@@ -447,28 +447,29 @@ static const yytype_uint8 yytranslate[] =
 static const yytype_uint8 yyprhs[] =
 {
        0,     0,     3,     5,     7,     9,    13,    16,    18,    21,
-      24,    28,    31,    35,    38,    42,    45,    47,    51,    53,
-      55,    57,    59,    61,    63,    65,    67
+      24,    28,    31,    35,    38,    42,    45,    47,    49,    51,
+      55,    57,    59,    61,    63,    65,    67,    69,    71
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 static const yytype_int8 yyrhs[] =
 {
-      21,     0,    -1,    22,    -1,     1,    -1,    23,    -1,    22,
-      13,    23,    -1,    22,    13,    -1,    24,    -1,    23,    24,
-      -1,    25,    14,    -1,    25,    14,    15,    -1,    25,    16,
-      -1,    25,    16,    15,    -1,    25,    15,    -1,    25,    15,
-      15,    -1,    25,     5,    -1,    25,    -1,    17,    22,    18,
-      -1,    19,    -1,     3,    -1,     7,    -1,     8,    -1,     9,
-      -1,    10,    -1,    11,    -1,    12,    -1,     6,    -1
+      23,     0,    -1,    24,    -1,     1,    -1,    25,    -1,    24,
+      13,    25,    -1,    24,    13,    -1,    26,    -1,    25,    26,
+      -1,    27,    14,    -1,    27,    14,    15,    -1,    27,    16,
+      -1,    27,    16,    15,    -1,    27,    15,    -1,    27,    15,
+      15,    -1,    27,     5,    -1,    27,    -1,    17,    -1,    18,
+      -1,    19,    24,    20,    -1,    21,    -1,     3,    -1,     7,
+      -1,     8,    -1,     9,    -1,    10,    -1,    11,    -1,    12,
+      -1,     6,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
        0,    86,    86,    91,    94,    98,   105,   120,   124,   132,
-     139,   148,   155,   164,   174,   185,   195,   201,   205,   212,
-     235,   242,   249,   256,   263,   270,   277
+     139,   148,   155,   164,   174,   185,   195,   199,   206,   215,
+     219,   226,   249,   256,   263,   270,   277,   284,   291
 };
 #endif
 
@@ -479,8 +480,9 @@ static const char *const yytname[] =
 {
   "$end", "error", "$undefined", "_CHAR_", "_ANY_", "_RANGE_", "_CLASS_",
   "_WORD_CHAR_", "_NON_WORD_CHAR_", "_SPACE_", "_NON_SPACE_", "_DIGIT_",
-  "_NON_DIGIT_", "'|'", "'*'", "'?'", "'+'", "'('", "')'", "'.'",
-  "$accept", "re", "alternative", "concatenation", "repeat", "single", 0
+  "_NON_DIGIT_", "'|'", "'*'", "'?'", "'+'", "'^'", "'$'", "'('", "')'",
+  "'.'", "$accept", "re", "alternative", "concatenation", "repeat",
+  "single", 0
 };
 #endif
 
@@ -490,24 +492,25 @@ static const char *const yytname[] =
 static const yytype_uint16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
-     265,   266,   267,   124,    42,    63,    43,    40,    41,    46
+     265,   266,   267,   124,    42,    63,    43,    94,    36,    40,
+      41,    46
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,    20,    21,    21,    22,    22,    22,    23,    23,    24,
-      24,    24,    24,    24,    24,    24,    24,    25,    25,    25,
-      25,    25,    25,    25,    25,    25,    25
+       0,    22,    23,    23,    24,    24,    24,    25,    25,    26,
+      26,    26,    26,    26,    26,    26,    26,    26,    26,    27,
+      27,    27,    27,    27,    27,    27,    27,    27,    27
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 static const yytype_uint8 yyr2[] =
 {
        0,     2,     1,     1,     1,     3,     2,     1,     2,     2,
-       3,     2,     3,     2,     3,     2,     1,     3,     1,     1,
-       1,     1,     1,     1,     1,     1,     1
+       3,     2,     3,     2,     3,     2,     1,     1,     1,     3,
+       1,     1,     1,     1,     1,     1,     1,     1,     1
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -515,31 +518,33 @@ static const yytype_uint8 yyr2[] =
    means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     3,    19,    26,    20,    21,    22,    23,    24,    25,
-       0,    18,     0,     2,     4,     7,    16,     0,     1,     6,
-       8,    15,     9,    13,    11,    17,     5,    10,    14,    12
+       0,     3,    21,    28,    22,    23,    24,    25,    26,    27,
+      17,    18,     0,    20,     0,     2,     4,     7,    16,     0,
+       1,     6,     8,    15,     9,    13,    11,    19,     5,    10,
+      14,    12
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 {
-      -1,    12,    13,    14,    15,    16
+      -1,    14,    15,    16,    17,    18
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -14
+#define YYPACT_NINF -16
 static const yytype_int8 yypact[] =
 {
-      -1,   -14,   -14,   -14,   -14,   -14,   -14,   -14,   -14,   -14,
-      14,   -14,     3,    -9,    14,   -14,    22,     1,   -14,    14,
-     -14,   -14,    -3,     0,    13,   -14,    14,   -14,   -14,   -14
+      -1,   -16,   -16,   -16,   -16,   -16,   -16,   -16,   -16,   -16,
+     -16,   -16,    16,   -16,     3,    -9,    16,   -16,    24,     1,
+     -16,    16,   -16,   -16,    -3,     0,    15,   -16,    16,   -16,
+     -16,   -16
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
-     -14,   -14,    19,    11,   -13,   -14
+     -16,   -16,    19,    11,   -15,   -16
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -549,18 +554,20 @@ static const yytype_int8 yypgoto[] =
 #define YYTABLE_NINF -1
 static const yytype_uint8 yytable[] =
 {
-       1,    20,     2,    18,    19,     3,     4,     5,     6,     7,
-       8,     9,    27,    20,    19,    28,    10,     2,    11,    25,
-       3,     4,     5,     6,     7,     8,     9,    21,    29,    17,
-      26,    10,     0,    11,     0,     0,    22,    23,    24
+       1,    22,     2,    20,    21,     3,     4,     5,     6,     7,
+       8,     9,    29,    22,    21,    30,    10,    11,    12,     2,
+      13,    27,     3,     4,     5,     6,     7,     8,     9,    23,
+      31,    19,    28,    10,    11,    12,     0,    13,    24,    25,
+      26
 };
 
 static const yytype_int8 yycheck[] =
 {
-       1,    14,     3,     0,    13,     6,     7,     8,     9,    10,
-      11,    12,    15,    26,    13,    15,    17,     3,    19,    18,
-       6,     7,     8,     9,    10,    11,    12,     5,    15,    10,
-      19,    17,    -1,    19,    -1,    -1,    14,    15,    16
+       1,    16,     3,     0,    13,     6,     7,     8,     9,    10,
+      11,    12,    15,    28,    13,    15,    17,    18,    19,     3,
+      21,    20,     6,     7,     8,     9,    10,    11,    12,     5,
+      15,    12,    21,    17,    18,    19,    -1,    21,    14,    15,
+      16
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -568,8 +575,9 @@ static const yytype_int8 yycheck[] =
 static const yytype_uint8 yystos[] =
 {
        0,     1,     3,     6,     7,     8,     9,    10,    11,    12,
-      17,    19,    21,    22,    23,    24,    25,    22,     0,    13,
-      24,     5,    14,    15,    16,    18,    23,    15,    15,    15
+      17,    18,    19,    21,    23,    24,    25,    26,    27,    24,
+       0,    13,    26,     5,    14,    15,    16,    20,    25,    15,
+      15,    15
 };
 
 #define yyerrok		(yyerrstatus = 0)
@@ -1092,7 +1100,7 @@ yydestruct (yymsg, yytype, yyvaluep, yyscanner, lex_env)
       case 6: /* "_CLASS_" */
 #line 79 "re_grammar.y"
 	{ yr_free((yyvaluep->class_vector)); };
-#line 1096 "re_grammar.c"
+#line 1104 "re_grammar.c"
 	break;
 
       default:
@@ -1550,24 +1558,44 @@ yyreduce:
     break;
 
   case 17:
-#line 202 "re_grammar.y"
+#line 200 "re_grammar.y"
     {
-            (yyval.re_node) = (yyvsp[(2) - (3)].re_node);
+            mark_as_not_literal();
+            (yyval.re_node) = yr_re_node_create(RE_NODE_ANCHOR_START, NULL, NULL);
+
+            ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
          }
     break;
 
   case 18:
-#line 206 "re_grammar.y"
+#line 207 "re_grammar.y"
     {
             mark_as_not_literal();
-            (yyval.re_node) = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+            (yyval.re_node) = yr_re_node_create(RE_NODE_ANCHOR_END, NULL, NULL);
 
             ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
          }
     break;
 
   case 19:
-#line 213 "re_grammar.y"
+#line 216 "re_grammar.y"
+    {
+            (yyval.re_node) = (yyvsp[(2) - (3)].re_node);
+         }
+    break;
+
+  case 20:
+#line 220 "re_grammar.y"
+    {
+            mark_as_not_literal();
+            (yyval.re_node) = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
+
+            ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
+         }
+    break;
+
+  case 21:
+#line 227 "re_grammar.y"
     {
             RE* re = yyget_extra(yyscanner);
 
@@ -1592,8 +1620,8 @@ yyreduce:
          }
     break;
 
-  case 20:
-#line 236 "re_grammar.y"
+  case 22:
+#line 250 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_WORD_CHAR, NULL, NULL);
@@ -1602,8 +1630,8 @@ yyreduce:
          }
     break;
 
-  case 21:
-#line 243 "re_grammar.y"
+  case 23:
+#line 257 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_NON_WORD_CHAR, NULL, NULL);
@@ -1612,8 +1640,8 @@ yyreduce:
          }
     break;
 
-  case 22:
-#line 250 "re_grammar.y"
+  case 24:
+#line 264 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_SPACE, NULL, NULL);
@@ -1622,8 +1650,8 @@ yyreduce:
          }
     break;
 
-  case 23:
-#line 257 "re_grammar.y"
+  case 25:
+#line 271 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_NON_SPACE, NULL, NULL);
@@ -1632,8 +1660,8 @@ yyreduce:
          }
     break;
 
-  case 24:
-#line 264 "re_grammar.y"
+  case 26:
+#line 278 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_DIGIT, NULL, NULL);
@@ -1642,8 +1670,8 @@ yyreduce:
          }
     break;
 
-  case 25:
-#line 271 "re_grammar.y"
+  case 27:
+#line 285 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_NON_DIGIT, NULL, NULL);
@@ -1652,8 +1680,8 @@ yyreduce:
          }
     break;
 
-  case 26:
-#line 278 "re_grammar.y"
+  case 28:
+#line 292 "re_grammar.y"
     {
             mark_as_not_literal();
             (yyval.re_node) = yr_re_node_create(RE_NODE_CLASS, NULL, NULL);
@@ -1666,7 +1694,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 1670 "re_grammar.c"
+#line 1698 "re_grammar.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1880,7 +1908,7 @@ yyreturn:
 }
 
 
-#line 289 "re_grammar.y"
+#line 303 "re_grammar.y"
 
 
 
diff --git a/libyara/re_grammar.y b/libyara/re_grammar.y
index ee389f3..0e9ca88 100644
--- a/libyara/re_grammar.y
+++ b/libyara/re_grammar.y
@@ -196,6 +196,20 @@ repeat : single '*'
          {
             $$ = $1;
          }
+       | '^'
+         {
+            mark_as_not_literal();
+            $$ = yr_re_node_create(RE_NODE_ANCHOR_START, NULL, NULL);
+
+            ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+         }
+       | '$'
+         {
+            mark_as_not_literal();
+            $$ = yr_re_node_create(RE_NODE_ANCHOR_END, NULL, NULL);
+
+            ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
+         }
        ;
 
 single : '(' alternative ')'
diff --git a/libyara/re_lexer.c b/libyara/re_lexer.c
index b0fc654..11b0aa9 100644
--- a/libyara/re_lexer.c
+++ b/libyara/re_lexer.c
@@ -362,8 +362,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
 
-#define YY_NUM_RULES 29
-#define YY_END_OF_BUFFER 30
+#define YY_NUM_RULES 27
+#define YY_END_OF_BUFFER 28
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -371,12 +371,12 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static yyconst flex_int16_t yy_accept[41] =
+static yyconst flex_int16_t yy_accept[39] =
     {   0,
-        0,    0,    0,    0,   30,    9,    9,    2,   28,    8,
-       16,    9,    1,   27,   26,   17,    7,    5,   15,   13,
-       11,   14,   12,   10,    0,    0,    0,   25,   23,   21,
-       19,   24,   22,   20,    6,    0,    3,    4,   18,    0
+        0,    0,    0,    0,   28,    7,    7,   26,    6,   14,
+        7,   25,   24,   15,    5,    3,   13,   11,    9,   12,
+       10,    8,    0,    0,    0,   23,   21,   19,   17,   22,
+       20,   18,    4,    0,    1,    2,   16,    0
     } ;
 
 static yyconst flex_int32_t yy_ec[256] =
@@ -384,17 +384,17 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    3,    1,    1,    1,    4,
-        4,    4,    4,    5,    6,    4,    1,    7,    7,    7,
-        7,    7,    7,    7,    7,    7,    7,    1,    1,    1,
-        1,    1,    4,    1,    1,    1,    1,    8,    1,    1,
+        1,    1,    1,    1,    1,    3,    1,    1,    1,    3,
+        3,    3,    3,    4,    5,    3,    1,    6,    6,    6,
+        6,    6,    6,    6,    6,    6,    6,    1,    1,    1,
+        1,    1,    3,    1,    1,    1,    1,    7,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    9,    1,    1,    1,   10,    1,    1,    1,
-       11,   12,   13,   14,    1,    1,    1,    1,    1,   15,
+        1,    1,    8,    1,    1,    1,    9,    1,    1,    1,
+       10,   11,   12,   13,    1,    1,    1,    1,    1,   14,
 
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,   16,    1,    1,    1,   17,    1,
-        1,    1,   18,    4,   19,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,   15,    1,    1,    1,   16,    1,
+        1,    1,   17,    3,   18,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -411,65 +411,65 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst flex_int32_t yy_meta[20] =
+static yyconst flex_int32_t yy_meta[19] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    2,    1,    1,    1,    1,    1,    1
+        1,    2,    1,    1,    1,    1,    1,    1
     } ;
 
-static yyconst flex_int16_t yy_base[44] =
+static yyconst flex_int16_t yy_base[42] =
     {   0,
-        0,   17,    3,   10,   32,   75,   75,   75,   75,   11,
-       28,    0,   75,   20,   38,   11,   75,    0,   75,   75,
-       75,   75,   75,   75,   20,   51,    0,   75,   75,   75,
-       75,   75,   75,   75,   75,   23,   75,   75,   75,   75,
-       70,   72,    0
+        0,   16,    3,    9,   32,   73,   73,   73,   10,   27,
+        0,   26,   37,   25,   73,   13,   73,   73,   73,   73,
+       73,   73,    6,   50,    0,   73,   73,   73,   73,   73,
+       73,   73,   73,   10,   73,   73,   73,   73,   68,   70,
+        0
     } ;
 
-static yyconst flex_int16_t yy_def[44] =
+static yyconst flex_int16_t yy_def[42] =
     {   0,
-       41,   41,   42,   42,   40,   40,   40,   40,   40,   40,
-       40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
-       40,   40,   40,   40,   40,   40,   43,   40,   40,   40,
-       40,   40,   40,   40,   40,   40,   40,   40,   40,    0,
-       40,   40,   40
+       39,   39,   40,   40,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   41,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,    0,   38,   38,
+       38
     } ;
 
-static yyconst flex_int16_t yy_nxt[95] =
+static yyconst flex_int16_t yy_nxt[92] =
     {   0,
-       39,    7,    8,    9,   25,   40,   26,   40,   40,   40,
-       10,   11,   35,    9,   15,   16,   27,   12,    7,    8,
-        9,   15,   16,   17,   18,   27,   36,   10,   11,   36,
-       13,   40,   40,   40,   12,   19,   20,   21,   37,   40,
-       40,   37,   22,   23,   24,   28,   29,   30,   40,   40,
-       31,   40,   32,   33,   34,   25,   40,   26,   40,   40,
-       40,   40,   40,   40,   40,   40,   40,   40,   40,   38,
-        6,    6,   14,   14,    5,   40,   40,   40,   40,   40,
-       40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
-       40,   40,   40,   40
+       37,    7,    8,   23,   38,   24,   38,   38,   38,    9,
+       10,   34,    8,   13,   14,   34,   11,    7,    8,   13,
+       14,   15,   16,   35,   33,    9,   10,   35,    8,   25,
+       25,   38,   11,   17,   18,   19,   38,   38,   38,   38,
+       20,   21,   22,   26,   27,   28,   38,   38,   29,   38,
+       30,   31,   32,   23,   38,   24,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   36,    6,    6,
+       12,   12,    5,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38
 
     } ;
 
-static yyconst flex_int16_t yy_chk[95] =
+static yyconst flex_int16_t yy_chk[92] =
     {   0,
-       43,    1,    1,    1,   12,    0,   12,    0,    0,    0,
-        1,    1,   18,    1,    3,    3,   16,    1,    2,    2,
-        2,    4,    4,   10,   10,   14,   25,    2,    2,   36,
-        2,    5,    0,    0,    2,   11,   11,   11,   25,    0,
-        0,   36,   11,   11,   11,   15,   15,   15,    0,    0,
-       15,    0,   15,   15,   15,   26,    0,   26,    0,    0,
-        0,    0,    0,    0,    0,    0,    0,    0,    0,   26,
-       41,   41,   42,   42,   40,   40,   40,   40,   40,   40,
-       40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
-       40,   40,   40,   40
+       41,    1,    1,   11,    0,   11,    0,    0,    0,    1,
+        1,   23,    1,    3,    3,   34,    1,    2,    2,    4,
+        4,    9,    9,   23,   16,    2,    2,   34,    2,   14,
+       12,    5,    2,   10,   10,   10,    0,    0,    0,    0,
+       10,   10,   10,   13,   13,   13,    0,    0,   13,    0,
+       13,   13,   13,   24,    0,   24,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,   24,   39,   39,
+       40,   40,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38
 
     } ;
 
 /* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[30] =
+static yyconst flex_int32_t yy_rule_can_match_eol[28] =
     {   0,
-0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
-    0, 0, 0, 0, 0, 0, 0, 1, 0, 0,     };
+0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
+    0, 0, 0, 0, 0, 1, 0, 0,     };
 
 /* The intent behind this definition is that it'll catch
  * any uses of REJECT which flex missed.
@@ -738,9 +738,6 @@ extern int re_yylex \
 #endif
 
 #define YY_RULE_SETUP \
-	if ( yyleng > 0 ) \
-		YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
-				(yytext[yyleng - 1] == '\n'); \
 	YY_USER_ACTION
 
 /** The main scanner function which does all the work.
@@ -755,7 +752,7 @@ YY_DECL
 #line 55 "re_lexer.l"
 
 
-#line 759 "re_lexer.c"
+#line 756 "re_lexer.c"
 
     yylval = yylval_param;
 
@@ -798,7 +795,6 @@ YY_DECL
 		yy_bp = yy_cp;
 
 		yy_current_state = yyg->yy_start;
-		yy_current_state += YY_AT_BOL();
 yy_match:
 		do
 			{
@@ -811,13 +807,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 41 )
+				if ( yy_current_state >= 39 )
 					yy_c = yy_meta[(unsigned int) yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			++yy_cp;
 			}
-		while ( yy_base[yy_current_state] != 75 );
+		while ( yy_base[yy_current_state] != 73 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -858,33 +854,6 @@ YY_RULE_SETUP
 #line 57 "re_lexer.l"
 {
 
-  // If ^ was found just at the beginning of the regexp
-  // then we have an achored regexp.
-
-  RE* re = re_yyget_extra(yyscanner);
-  re->flags |= RE_FLAGS_START_ANCHORED;
-}
-	YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 67 "re_lexer.l"
-{
-
-  // In a perfect world we would be able to detect a trailing $
-  // by using \$$, just as we did with ^\^ for detecting the
-  // leading ^. However in the real world this doesn't work. We
-  // are forced to match every $ and take note of the position
-  // where it was seen for the last time. At the end of the regexp
-  // we verify if a $ was found just before the end.
-
-  LEX_ENV->last_dollar = yytext;
-}
-	YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 80 "re_lexer.l"
-{
-
   // Examples: {3,8} {0,5} {,5} {7,}
 
   int hi_bound;
@@ -916,9 +885,9 @@ YY_RULE_SETUP
   return _RANGE_;
 }
 	YY_BREAK
-case 4:
+case 2:
 YY_RULE_SETUP
-#line 114 "re_lexer.l"
+#line 91 "re_lexer.l"
 {
 
   // Example: {10}
@@ -936,9 +905,9 @@ YY_RULE_SETUP
   return _RANGE_;
 }
 	YY_BREAK
-case 5:
+case 3:
 YY_RULE_SETUP
-#line 132 "re_lexer.l"
+#line 109 "re_lexer.l"
 {
 
   // Start of a negated character class. Example: [^abcd]
@@ -948,9 +917,9 @@ YY_RULE_SETUP
   LEX_ENV->negated_class = TRUE;
 }
 	YY_BREAK
-case 6:
+case 4:
 YY_RULE_SETUP
-#line 141 "re_lexer.l"
+#line 118 "re_lexer.l"
 {
 
   // Start of character negated class containing a ].
@@ -963,9 +932,9 @@ YY_RULE_SETUP
   LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
 }
 	YY_BREAK
-case 7:
+case 5:
 YY_RULE_SETUP
-#line 154 "re_lexer.l"
+#line 131 "re_lexer.l"
 {
 
   // Start of character class containing a ].
@@ -978,9 +947,9 @@ YY_RULE_SETUP
   LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
 }
 	YY_BREAK
-case 8:
+case 6:
 YY_RULE_SETUP
-#line 167 "re_lexer.l"
+#line 144 "re_lexer.l"
 {
 
   // Start of character class. Example: [abcd]
@@ -990,10 +959,10 @@ YY_RULE_SETUP
   LEX_ENV->negated_class = FALSE;
 }
 	YY_BREAK
-case 9:
-/* rule 9 can match eol */
+case 7:
+/* rule 7 can match eol */
 YY_RULE_SETUP
-#line 177 "re_lexer.l"
+#line 154 "re_lexer.l"
 {
 
   // Any non-special character is passed as a CHAR token to the scanner.
@@ -1002,59 +971,59 @@ YY_RULE_SETUP
   return _CHAR_;
 }
 	YY_BREAK
-case 10:
+case 8:
 YY_RULE_SETUP
-#line 186 "re_lexer.l"
+#line 163 "re_lexer.l"
 {
   return _WORD_CHAR_;
 }
 	YY_BREAK
-case 11:
+case 9:
 YY_RULE_SETUP
-#line 191 "re_lexer.l"
+#line 168 "re_lexer.l"
 {
   return _NON_WORD_CHAR_;
 }
 	YY_BREAK
-case 12:
+case 10:
 YY_RULE_SETUP
-#line 196 "re_lexer.l"
+#line 173 "re_lexer.l"
 {
   return _SPACE_;
 }
 	YY_BREAK
-case 13:
+case 11:
 YY_RULE_SETUP
-#line 201 "re_lexer.l"
+#line 178 "re_lexer.l"
 {
   return _NON_SPACE_;
 }
 	YY_BREAK
-case 14:
+case 12:
 YY_RULE_SETUP
-#line 206 "re_lexer.l"
+#line 183 "re_lexer.l"
 {
   return _DIGIT_;
 }
 	YY_BREAK
-case 15:
+case 13:
 YY_RULE_SETUP
-#line 211 "re_lexer.l"
+#line 188 "re_lexer.l"
 {
   return _NON_DIGIT_;
 }
 	YY_BREAK
-case 16:
+case 14:
 YY_RULE_SETUP
-#line 216 "re_lexer.l"
+#line 193 "re_lexer.l"
 {
   yylval->integer = read_escaped_char(yyscanner);
   return _CHAR_;
 }
 	YY_BREAK
-case 17:
+case 15:
 YY_RULE_SETUP
-#line 222 "re_lexer.l"
+#line 199 "re_lexer.l"
 {
 
   // End of character class.
@@ -1074,10 +1043,10 @@ YY_RULE_SETUP
   return _CLASS_;
 }
 	YY_BREAK
-case 18:
-/* rule 18 can match eol */
+case 16:
+/* rule 16 can match eol */
 YY_RULE_SETUP
-#line 242 "re_lexer.l"
+#line 219 "re_lexer.l"
 {
 
   // A range inside a character class.
@@ -1104,17 +1073,17 @@ YY_RULE_SETUP
   }
 }
 	YY_BREAK
-case 19:
+case 17:
 YY_RULE_SETUP
-#line 269 "re_lexer.l"
+#line 246 "re_lexer.l"
 {
 
   LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
 }
 	YY_BREAK
-case 20:
+case 18:
 YY_RULE_SETUP
-#line 275 "re_lexer.l"
+#line 252 "re_lexer.l"
 {
 
   int i;
@@ -1127,9 +1096,9 @@ YY_RULE_SETUP
     LEX_ENV->class_vector[i] |= word_chars[i];
 }
 	YY_BREAK
-case 21:
+case 19:
 YY_RULE_SETUP
-#line 288 "re_lexer.l"
+#line 265 "re_lexer.l"
 {
 
   int i;
@@ -1142,18 +1111,18 @@ YY_RULE_SETUP
     LEX_ENV->class_vector[i] |= ~word_chars[i];
 }
 	YY_BREAK
-case 22:
+case 20:
 YY_RULE_SETUP
-#line 301 "re_lexer.l"
+#line 278 "re_lexer.l"
 {
 
   LEX_ENV->class_vector[' ' / 8] |= 1 << ' ' % 8;
   LEX_ENV->class_vector['\t' / 8] |= 1 << '\t' % 8;
 }
 	YY_BREAK
-case 23:
+case 21:
 YY_RULE_SETUP
-#line 308 "re_lexer.l"
+#line 285 "re_lexer.l"
 {
 
   int i;
@@ -1165,9 +1134,9 @@ YY_RULE_SETUP
   LEX_ENV->class_vector['\t' / 8] &= ~(1 << '\t' % 8);
 }
 	YY_BREAK
-case 24:
+case 22:
 YY_RULE_SETUP
-#line 320 "re_lexer.l"
+#line 297 "re_lexer.l"
 {
 
   char c;
@@ -1176,9 +1145,9 @@ YY_RULE_SETUP
     LEX_ENV->class_vector[c / 8] |= 1 << c % 8;
 }
 	YY_BREAK
-case 25:
+case 23:
 YY_RULE_SETUP
-#line 329 "re_lexer.l"
+#line 306 "re_lexer.l"
 {
 
   int i;
@@ -1191,19 +1160,19 @@ YY_RULE_SETUP
     LEX_ENV->class_vector[c / 8] &= ~(1 << c % 8);
 }
 	YY_BREAK
-case 26:
+case 24:
 YY_RULE_SETUP
-#line 342 "re_lexer.l"
+#line 319 "re_lexer.l"
 {
 
   uint8_t c = read_escaped_char(yyscanner);
   unput(c);
 }
 	YY_BREAK
-case 27:
-/* rule 27 can match eol */
+case 25:
+/* rule 25 can match eol */
 YY_RULE_SETUP
-#line 349 "re_lexer.l"
+#line 326 "re_lexer.l"
 {
 
   // A character class (i.e: [0-9a-f]) is represented by a 256-bits vector,
@@ -1213,7 +1182,7 @@ YY_RULE_SETUP
 }
 	YY_BREAK
 case YY_STATE_EOF(char_class):
-#line 358 "re_lexer.l"
+#line 335 "re_lexer.l"
 {
 
   // End of regexp reached while scanning a character class.
@@ -1222,9 +1191,9 @@ case YY_STATE_EOF(char_class):
   yyterminate();
 }
 	YY_BREAK
-case 28:
+case 26:
 YY_RULE_SETUP
-#line 367 "re_lexer.l"
+#line 344 "re_lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -1239,27 +1208,18 @@ YY_RULE_SETUP
 }
 	YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 381 "re_lexer.l"
+#line 358 "re_lexer.l"
 {
 
-  // If $ was found just before the end of the regexp
-  // then we have an achored regexp.
-
-  if (yytext == LEX_ENV->last_dollar + 1)
-  {
-    RE* re = re_yyget_extra(yyscanner);
-    re->flags |= RE_FLAGS_END_ANCHORED;
-  }
-
   yyterminate();
 }
 	YY_BREAK
-case 29:
+case 27:
 YY_RULE_SETUP
-#line 395 "re_lexer.l"
+#line 363 "re_lexer.l"
 ECHO;
 	YY_BREAK
-#line 1263 "re_lexer.c"
+#line 1223 "re_lexer.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -1539,7 +1499,6 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	yy_current_state = yyg->yy_start;
-	yy_current_state += YY_AT_BOL();
 
 	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
 		{
@@ -1552,7 +1511,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 41 )
+			if ( yy_current_state >= 39 )
 				yy_c = yy_meta[(unsigned int) yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1581,11 +1540,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 41 )
+		if ( yy_current_state >= 39 )
 			yy_c = yy_meta[(unsigned int) yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-	yy_is_jam = (yy_current_state == 40);
+	yy_is_jam = (yy_current_state == 38);
 
 	return yy_is_jam ? 0 : yy_current_state;
 }
@@ -1703,8 +1662,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
 	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
 
-	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
-	if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )
+	if ( c == '\n' )
 		   
     do{ yylineno++;
         yycolumn=0;
@@ -2436,7 +2394,7 @@ void re_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 395 "re_lexer.l"
+#line 363 "re_lexer.l"
 
 
 
@@ -2502,7 +2460,6 @@ int yr_parse_re_string(
   yyscan_t yyscanner;
   LEX_ENVIRONMENT lex_env;
 
-  lex_env.last_dollar = NULL;
   lex_env.last_error_message = NULL;
 
   FAIL_ON_ERROR(yr_re_create(re));
diff --git a/libyara/re_lexer.h b/libyara/re_lexer.h
index d2a8f16..5327ac2 100644
--- a/libyara/re_lexer.h
+++ b/libyara/re_lexer.h
@@ -40,7 +40,6 @@ typedef struct _LEX_ENVIRONMENT
 {
   int negated_class;
   uint8_t class_vector[32];
-  const char* last_dollar;
   const char* last_error_message;
 
 } LEX_ENVIRONMENT;
diff --git a/libyara/re_lexer.l b/libyara/re_lexer.l
index b6e03dc..050b487 100644
--- a/libyara/re_lexer.l
+++ b/libyara/re_lexer.l
@@ -54,29 +54,6 @@ hex_digit     [0-9a-fA-F]
 
 %%
 
-^\^ {
-
-  // If ^ was found just at the beginning of the regexp
-  // then we have an achored regexp.
-
-  RE* re = yyget_extra(yyscanner);
-  re->flags |= RE_FLAGS_START_ANCHORED;
-}
-
-
-\$ {
-
-  // In a perfect world we would be able to detect a trailing $
-  // by using \$$, just as we did with ^\^ for detecting the
-  // leading ^. However in the real world this doesn't work. We
-  // are forced to match every $ and take note of the position
-  // where it was seen for the last time. At the end of the regexp
-  // we verify if a $ was found just before the end.
-
-  LEX_ENV->last_dollar = yytext;
-}
-
-
 \{{digit}*,{digit}*\} {
 
   // Examples: {3,8} {0,5} {,5} {7,}
@@ -380,15 +357,6 @@ hex_digit     [0-9a-fA-F]
 
 <<EOF>> {
 
-  // If $ was found just before the end of the regexp
-  // then we have an achored regexp.
-
-  if (yytext == LEX_ENV->last_dollar + 1)
-  {
-    RE* re = yyget_extra(yyscanner);
-    re->flags |= RE_FLAGS_END_ANCHORED;
-  }
-
   yyterminate();
 }
 
@@ -456,7 +424,6 @@ int yr_parse_re_string(
   yyscan_t yyscanner;
   LEX_ENVIRONMENT lex_env;
 
-  lex_env.last_dollar = NULL;
   lex_env.last_error_message = NULL;
 
   FAIL_ON_ERROR(yr_re_create(re));
diff --git a/libyara/rules.c b/libyara/rules.c
index d20ead1..bfbf264 100644
--- a/libyara/rules.c
+++ b/libyara/rules.c
@@ -332,13 +332,6 @@ void match_callback(
   // total match length is the sum of backward and forward matches.
   match_length = match_length + callback_args->forward_matches;
 
-  if (flags & RE_FLAGS_START_ANCHORED && match_offset > 0)
-    return;
-
-  if (flags & RE_FLAGS_END_ANCHORED &&
-      match_offset + match_length != callback_args->data_size)
-    return;
-
   if (callback_args->full_word)
   {
     if (flags & RE_FLAGS_WIDE)
@@ -459,12 +452,6 @@ int _yr_scan_verify_re_match(
   else
     exec = yr_re_exec;
 
-  if (STRING_IS_START_ANCHORED(ac_match->string))
-    flags |= RE_FLAGS_START_ANCHORED;
-
-  if (STRING_IS_END_ANCHORED(ac_match->string))
-    flags |= RE_FLAGS_END_ANCHORED;
-
   if (STRING_IS_NO_CASE(ac_match->string))
     flags |= RE_FLAGS_NO_CASE;
 
@@ -622,12 +609,6 @@ int _yr_scan_verify_literal_match(
       }
     }
 
-    if (STRING_IS_START_ANCHORED(string))
-      flags |= RE_FLAGS_START_ANCHORED;
-
-    if (STRING_IS_END_ANCHORED(string))
-      flags |= RE_FLAGS_END_ANCHORED;
-
     callback_args.string = string;
     callback_args.data = data;
     callback_args.data_size = data_size;
diff --git a/libyara/yara.h b/libyara/yara.h
index b634cc7..63a9adf 100644
--- a/libyara/yara.h
+++ b/libyara/yara.h
@@ -165,10 +165,8 @@ typedef pthread_mutex_t mutex_t;
 #define STRING_GFLAGS_ANONYMOUS         0x100
 #define STRING_GFLAGS_SINGLE_MATCH      0x200
 #define STRING_GFLAGS_LITERAL           0x400
-#define STRING_GFLAGS_START_ANCHORED    0x800
-#define STRING_GFLAGS_END_ANCHORED      0x1000
-#define STRING_GFLAGS_FITS_IN_ATOM      0x2000
-#define STRING_GFLAGS_NULL              0x4000
+#define STRING_GFLAGS_FITS_IN_ATOM      0x800
+#define STRING_GFLAGS_NULL              0x1000
 
 #define STRING_IS_HEX(x) \
     (((x)->g_flags) & STRING_GFLAGS_HEXADECIMAL)
@@ -203,12 +201,6 @@ typedef pthread_mutex_t mutex_t;
 #define STRING_IS_FAST_HEX_REGEXP(x) \
     (((x)->g_flags) & STRING_GFLAGS_FAST_HEX_REGEXP)
 
-#define STRING_IS_START_ANCHORED(x) \
-    (((x)->g_flags) & STRING_GFLAGS_START_ANCHORED)
-
-#define STRING_IS_END_ANCHORED(x) \
-    (((x)->g_flags) & STRING_GFLAGS_END_ANCHORED)
-
 #define STRING_IS_NULL(x) \
     ((x) == NULL || ((x)->g_flags) & STRING_GFLAGS_NULL)
 

-- 
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