[Forensics-changes] [yara] 99/407: Fix issues with pull request #184

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:14 UTC 2017


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

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

commit 3a8bd424df68702b8d51e4c3637a54077cf7dd11
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Mon Oct 13 12:30:22 2014 +0200

    Fix issues with pull request #184
---
 libyara/exec.c                 | 118 +++----
 libyara/grammar.c              | 689 +++++++++++++++++++----------------------
 libyara/grammar.y              |  64 +---
 libyara/include/yara/exec.h    |  18 +-
 libyara/include/yara/modules.h |   1 +
 libyara/modules/tests.c        |   3 +-
 libyara/object.c               |  22 +-
 libyara/parser.c               |   8 +-
 8 files changed, 428 insertions(+), 495 deletions(-)

diff --git a/libyara/exec.c b/libyara/exec.c
index 44c7e2b..3bb7add 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -87,8 +87,9 @@ int yr_execute_code(
   YR_MATCH* match;
   YR_OBJECT* object;
   YR_OBJECT_FUNCTION* function;
-  SIZED_STRING *big;
-  YR_STRING *little;
+
+  SIZED_STRING* sized_str_1;
+  SIZED_STRING* sized_str_2;
 
   char* identifier;
   char* args_fmt;
@@ -265,35 +266,65 @@ int yr_execute_code(
         push(COMPARISON(!=, r1, r2));
         break;
 
-      case OP_SZ_EQ:
+      case OP_STR_EQ:
         pop(r2);
         pop(r1);
 
         if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
+        {
           push(UNDEFINED);
+        }
         else
-          push(strcmp(UINT64_TO_PTR(char*, r1),
-                      UINT64_TO_PTR(char*, r2)) == 0);
+        {
+          sized_str_1 = UINT64_TO_PTR(SIZED_STRING*, r1);
+          sized_str_2 = UINT64_TO_PTR(SIZED_STRING*, r2);
+
+          if (sized_str_1->length == sized_str_2->length)
+          {
+            push(memcmp(sized_str_1->c_string,
+                        sized_str_2->c_string,
+                        sized_str_2->length) == 0);
+          }
+          else
+          {
+            push(FALSE);
+          }
+        }
         break;
 
-      case OP_SZ_NEQ:
+      case OP_STR_NEQ:
         pop(r2);
         pop(r1);
 
         if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
+        {
           push(UNDEFINED);
+        }
         else
-          push(strcmp(UINT64_TO_PTR(char*, r1),
-                      UINT64_TO_PTR(char*, r2)) != 0);
+        {
+          sized_str_1 = UINT64_TO_PTR(SIZED_STRING*, r1);
+          sized_str_2 = UINT64_TO_PTR(SIZED_STRING*, r2);
+
+          if (sized_str_1->length == sized_str_2->length)
+          {
+            push(memcmp(sized_str_1->c_string,
+                        sized_str_2->c_string,
+                        sized_str_2->length) != 0);
+          }
+          else
+          {
+            push(TRUE);
+          }
+        }
         break;
 
-      case OP_SZ_TO_BOOL:
+      case OP_STR_TO_BOOL:
         pop(r1);
 
         if (IS_UNDEFINED(r1))
           push(UNDEFINED);
         else
-          push(strlen(UINT64_TO_PTR(char*, r1)) > 0);
+          push(UINT64_TO_PTR(SIZED_STRING*, r1)->length > 0);
 
         break;
 
@@ -478,7 +509,7 @@ int yr_execute_code(
         assert(object->type == OBJECT_TYPE_DICTIONARY);
 
         object = yr_object_dict_get_item(
-            object, 0, UINT64_TO_PTR(const char*, r1));
+            object, 0, UINT64_TO_PTR(SIZED_STRING*, r1)->c_string);
 
         if (object != NULL)
           push(PTR_TO_UINT64(object));
@@ -531,13 +562,13 @@ int yr_execute_code(
 
         break;
 
-      case OP_STR_FOUND:
+      case OP_FOUND:
         pop(r1);
         string = UINT64_TO_PTR(YR_STRING*, r1);
         push(string->matches[tidx].tail != NULL ? 1 : 0);
         break;
 
-      case OP_STR_FOUND_AT:
+      case OP_FOUND_AT:
         pop(r2);
         pop(r1);
 
@@ -571,7 +602,7 @@ int yr_execute_code(
 
         break;
 
-      case OP_STR_FOUND_IN:
+      case OP_FOUND_IN:
         pop(r3);
         pop(r2);
         pop(r1);
@@ -606,13 +637,13 @@ int yr_execute_code(
 
         break;
 
-      case OP_STR_COUNT:
+      case OP_COUNT:
         pop(r1);
         string = UINT64_TO_PTR(YR_STRING*, r1);
         push(string->matches[tidx].count);
         break;
 
-      case OP_STR_OFFSET:
+      case OP_OFFSET:
         pop(r2);
         pop(r1);
 
@@ -710,10 +741,17 @@ int yr_execute_code(
         pop(r1);
 
         if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
+        {
           push(UNDEFINED);
+        }
         else
-          push(strstr(UINT64_TO_PTR(char*, r1),
-                      UINT64_TO_PTR(char*, r2)) != NULL);
+        {
+          sized_str_1 = UINT64_TO_PTR(SIZED_STRING*, r1);
+          sized_str_2 = UINT64_TO_PTR(SIZED_STRING*, r2);
+
+          push(memmem(sized_str_1->c_string, sized_str_1->length,
+                      sized_str_2->c_string, sized_str_2->length) != NULL);
+        }
         break;
 
       case OP_IMPORT:
@@ -730,9 +768,9 @@ int yr_execute_code(
         pop(r2);
         pop(r1);
 
-        count = strlen(UINT64_TO_PTR(char*, r1));
+        sized_str_1 = UINT64_TO_PTR(SIZED_STRING*, r1);
 
-        if (count == 0)
+        if (sized_str_1->length == 0)
         {
           push(FALSE);
           break;
@@ -740,8 +778,8 @@ int yr_execute_code(
 
         result = yr_re_exec(
           UINT64_TO_PTR(uint8_t*, r2),
-          UINT64_TO_PTR(uint8_t*, r1),
-          count,
+          (uint8_t*) sized_str_1->c_string,
+          sized_str_1->length,
           RE_FLAGS_SCAN,
           NULL,
           NULL);
@@ -749,42 +787,6 @@ int yr_execute_code(
         push(result >= 0);
         break;
 
-      case OP_CONTAINS_STR:
-        pop(r2);
-        pop(r1);
-        big = UINT64_TO_PTR(SIZED_STRING*, r1);
-        little = UINT64_TO_PTR(YR_STRING*, r2);
-
-        if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
-        {
-          push(UNDEFINED);
-          break;
-        }
-
-        push(memmem(big->c_string, big->length, little->string, little->length) != NULL);
-        break;
-
-      case OP_MATCHES_STR:
-        pop(r2);
-        pop(r1);
-        big = UINT64_TO_PTR(SIZED_STRING*, r1);
-        little = UINT64_TO_PTR(YR_STRING*, r2);
-
-        if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
-        {
-          push(UNDEFINED);
-          break;
-        }
-
-        if (big->length != little->length)
-        {
-          push(FALSE);
-          break;
-        }
-
-        push(memcmp(big->c_string, little->string, big->length) == 0);
-        break;
-
       default:
         // Unknown instruction, this shouldn't happen.
         assert(FALSE);
diff --git a/libyara/grammar.c b/libyara/grammar.c
index dfc9487..0689b8b 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -514,16 +514,16 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  2
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   476
+#define YYLAST   433
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  74
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  35
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  117
+#define YYNRULES  115
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  218
+#define YYNSTATES  216
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
@@ -578,13 +578,13 @@ static const yytype_uint16 yyprhs[] =
       57,    59,    62,    64,    67,    71,    75,    79,    83,    85,
       88,    93,    94,   100,   104,   105,   108,   110,   112,   114,
      116,   118,   122,   127,   132,   133,   135,   139,   141,   143,
-     145,   147,   151,   155,   159,   163,   165,   169,   173,   174,
-     175,   187,   188,   198,   202,   205,   209,   213,   217,   221,
-     225,   229,   233,   237,   241,   243,   247,   251,   253,   260,
-     262,   266,   267,   272,   274,   276,   280,   282,   284,   286,
-     288,   290,   294,   296,   298,   303,   308,   313,   318,   323,
-     328,   330,   332,   334,   339,   341,   343,   347,   351,   355,
-     359,   363,   367,   371,   375,   378,   382,   386
+     145,   147,   151,   155,   157,   161,   165,   166,   167,   179,
+     180,   190,   194,   197,   201,   205,   209,   213,   217,   221,
+     225,   229,   233,   235,   239,   243,   245,   252,   254,   258,
+     259,   264,   266,   268,   272,   274,   276,   278,   280,   282,
+     286,   288,   290,   295,   300,   305,   310,   315,   320,   322,
+     324,   326,   331,   333,   335,   339,   343,   347,   351,   355,
+     359,   363,   367,   370,   374,   378
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
@@ -605,30 +605,29 @@ static const yytype_int8 yyrhs[] =
        9,    -1,    92,    69,   108,    70,    -1,    92,    71,    93,
       72,    -1,    -1,    96,    -1,    93,    73,    96,    -1,    17,
       -1,    96,    -1,    40,    -1,    41,    -1,   108,    37,    94,
-      -1,   108,    38,   108,    -1,   108,    38,    10,    -1,   108,
-      37,    10,    -1,    10,    -1,    10,    22,   108,    -1,    10,
-      27,   101,    -1,    -1,    -1,    29,   107,     9,    27,    97,
-     100,    66,    98,    71,    95,    72,    -1,    -1,    29,   107,
-      28,   103,    66,    99,    71,    95,    72,    -1,   107,    28,
-     103,    -1,    61,    95,    -1,    95,    43,    95,    -1,    95,
-      42,    95,    -1,   108,    53,   108,    -1,   108,    51,   108,
-      -1,   108,    52,   108,    -1,   108,    50,   108,    -1,   108,
-      49,   108,    -1,   108,    47,   108,    -1,   108,    48,   108,
-      -1,   108,    -1,    71,    96,    72,    -1,    71,   102,    72,
-      -1,   101,    -1,    71,   108,    68,    68,   108,    72,    -1,
-     108,    -1,   102,    73,   108,    -1,    -1,    71,   104,   105,
-      72,    -1,    30,    -1,   106,    -1,   105,    73,   106,    -1,
-      10,    -1,    13,    -1,   108,    -1,    25,    -1,    26,    -1,
-      71,   108,    72,    -1,    23,    -1,    24,    -1,    31,    71,
-     108,    72,    -1,    32,    71,   108,    72,    -1,    33,    71,
-     108,    72,    -1,    34,    71,   108,    72,    -1,    35,    71,
-     108,    72,    -1,    36,    71,   108,    72,    -1,    14,    -1,
-      15,    -1,    11,    -1,    12,    69,   108,    70,    -1,    12,
-      -1,    92,    -1,   108,    56,   108,    -1,   108,    57,   108,
-      -1,   108,    58,   108,    -1,   108,    59,   108,    -1,   108,
-      60,   108,    -1,   108,    46,   108,    -1,   108,    44,   108,
-      -1,   108,    45,   108,    -1,    62,   108,    -1,   108,    55,
-     108,    -1,   108,    54,   108,    -1,    94,    -1
+      -1,   108,    38,   108,    -1,    10,    -1,    10,    22,   108,
+      -1,    10,    27,   101,    -1,    -1,    -1,    29,   107,     9,
+      27,    97,   100,    66,    98,    71,    95,    72,    -1,    -1,
+      29,   107,    28,   103,    66,    99,    71,    95,    72,    -1,
+     107,    28,   103,    -1,    61,    95,    -1,    95,    43,    95,
+      -1,    95,    42,    95,    -1,   108,    53,   108,    -1,   108,
+      51,   108,    -1,   108,    52,   108,    -1,   108,    50,   108,
+      -1,   108,    49,   108,    -1,   108,    47,   108,    -1,   108,
+      48,   108,    -1,   108,    -1,    71,    96,    72,    -1,    71,
+     102,    72,    -1,   101,    -1,    71,   108,    68,    68,   108,
+      72,    -1,   108,    -1,   102,    73,   108,    -1,    -1,    71,
+     104,   105,    72,    -1,    30,    -1,   106,    -1,   105,    73,
+     106,    -1,    10,    -1,    13,    -1,   108,    -1,    25,    -1,
+      26,    -1,    71,   108,    72,    -1,    23,    -1,    24,    -1,
+      31,    71,   108,    72,    -1,    32,    71,   108,    72,    -1,
+      33,    71,   108,    72,    -1,    34,    71,   108,    72,    -1,
+      35,    71,   108,    72,    -1,    36,    71,   108,    72,    -1,
+      14,    -1,    15,    -1,    11,    -1,    12,    69,   108,    70,
+      -1,    12,    -1,    92,    -1,   108,    56,   108,    -1,   108,
+      57,   108,    -1,   108,    58,   108,    -1,   108,    59,   108,
+      -1,   108,    60,   108,    -1,   108,    46,   108,    -1,   108,
+      44,   108,    -1,   108,    45,   108,    -1,    62,   108,    -1,
+     108,    55,   108,    -1,   108,    54,   108,    -1,    94,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
@@ -639,13 +638,13 @@ static const yytype_uint16 yyrline[] =
      343,   356,   393,   394,   399,   415,   428,   441,   458,   459,
      464,   478,   477,   494,   511,   512,   517,   518,   519,   520,
      525,   613,   662,   712,   754,   757,   779,   812,   857,   874,
-     883,   892,   907,   921,   937,   953,   967,   983,   998,  1033,
-     997,  1144,  1143,  1220,  1226,  1232,  1238,  1246,  1255,  1264,
-    1273,  1282,  1309,  1336,  1363,  1367,  1375,  1376,  1381,  1403,
-    1415,  1431,  1430,  1436,  1445,  1446,  1451,  1456,  1465,  1466,
-    1470,  1478,  1482,  1492,  1505,  1517,  1529,  1541,  1553,  1565,
-    1577,  1587,  1610,  1625,  1640,  1662,  1699,  1709,  1719,  1729,
-    1739,  1749,  1759,  1769,  1779,  1789,  1799,  1809
+     883,   892,   907,   921,   935,   951,   966,  1001,   965,  1112,
+    1111,  1188,  1194,  1200,  1206,  1214,  1223,  1232,  1241,  1250,
+    1277,  1304,  1331,  1335,  1343,  1344,  1349,  1371,  1383,  1399,
+    1398,  1404,  1413,  1414,  1419,  1424,  1433,  1434,  1438,  1446,
+    1450,  1460,  1473,  1485,  1497,  1509,  1521,  1533,  1545,  1555,
+    1578,  1593,  1608,  1630,  1667,  1677,  1687,  1697,  1707,  1717,
+    1727,  1737,  1747,  1757,  1767,  1777
 };
 #endif
 
@@ -701,13 +700,13 @@ static const yytype_uint8 yyr1[] =
       84,    84,    85,    85,    86,    86,    86,    86,    87,    87,
       88,    89,    88,    88,    90,    90,    91,    91,    91,    91,
       92,    92,    92,    92,    93,    93,    93,    94,    95,    96,
-      96,    96,    96,    96,    96,    96,    96,    96,    97,    98,
-      96,    99,    96,    96,    96,    96,    96,    96,    96,    96,
-      96,    96,    96,    96,    96,    96,   100,   100,   101,   102,
-     102,   104,   103,   103,   105,   105,   106,   106,   107,   107,
-     107,   108,   108,   108,   108,   108,   108,   108,   108,   108,
+      96,    96,    96,    96,    96,    96,    97,    98,    96,    99,
+      96,    96,    96,    96,    96,    96,    96,    96,    96,    96,
+      96,    96,    96,    96,   100,   100,   101,   102,   102,   104,
+     103,   103,   105,   105,   106,   106,   107,   107,   107,   108,
      108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
-     108,   108,   108,   108,   108,   108,   108,   108
+     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
+     108,   108,   108,   108,   108,   108
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
@@ -718,13 +717,13 @@ static const yytype_uint8 yyr2[] =
        1,     2,     1,     2,     3,     3,     3,     3,     1,     2,
        4,     0,     5,     3,     0,     2,     1,     1,     1,     1,
        1,     3,     4,     4,     0,     1,     3,     1,     1,     1,
-       1,     3,     3,     3,     3,     1,     3,     3,     0,     0,
-      11,     0,     9,     3,     2,     3,     3,     3,     3,     3,
-       3,     3,     3,     3,     1,     3,     3,     1,     6,     1,
-       3,     0,     4,     1,     1,     3,     1,     1,     1,     1,
-       1,     3,     1,     1,     4,     4,     4,     4,     4,     4,
-       1,     1,     1,     4,     1,     1,     3,     3,     3,     3,
-       3,     3,     3,     3,     2,     3,     3,     1
+       1,     3,     3,     1,     3,     3,     0,     0,    11,     0,
+       9,     3,     2,     3,     3,     3,     3,     3,     3,     3,
+       3,     3,     1,     3,     3,     1,     6,     1,     3,     0,
+       4,     1,     1,     3,     1,     1,     1,     1,     1,     3,
+       1,     1,     4,     4,     4,     4,     4,     4,     1,     1,
+       1,     4,     1,     1,     3,     3,     3,     3,     3,     3,
+       3,     3,     2,     3,     3,     1
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -736,33 +735,33 @@ static const yytype_uint8 yydefact[] =
        7,     0,    16,    17,    15,    18,     0,     0,    20,    19,
        9,    21,     0,    11,     0,     0,     0,     0,    10,    22,
        0,     0,     0,     0,    23,     0,    12,    28,     0,     8,
-      25,    24,    26,    27,    31,    29,    40,    55,   102,   104,
-     100,   101,    47,    92,    93,    89,    90,     0,     0,     0,
-       0,     0,     0,     0,    49,    50,     0,     0,     0,   105,
-     117,    13,    48,     0,    74,    34,    33,     0,     0,     0,
-       0,     0,     0,    88,     0,     0,     0,     0,     0,     0,
-      64,   114,     0,    48,    74,     0,     0,    44,     0,     0,
+      25,    24,    26,    27,    31,    29,    40,    53,   100,   102,
+      98,    99,    47,    90,    91,    87,    88,     0,     0,     0,
+       0,     0,     0,     0,    49,    50,     0,     0,     0,   103,
+     115,    13,    48,     0,    72,    34,    33,     0,     0,     0,
+       0,     0,     0,    86,     0,     0,     0,     0,     0,     0,
+      62,   112,     0,    48,    72,     0,     0,    44,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-      30,    34,    56,     0,    57,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    75,    91,    41,     0,     0,
-      45,    66,    65,    83,    81,    63,    54,    51,    53,    52,
-     112,   113,   111,    72,    73,    71,    70,    68,    69,    67,
-     116,   115,   106,   107,   108,   109,   110,    37,    36,    38,
-      39,    35,    32,     0,   103,    58,     0,    94,    95,    96,
-      97,    98,    99,    42,    43,     0,     0,     0,     0,    61,
-      46,    86,    87,     0,    84,     0,     0,     0,    77,     0,
-      82,     0,     0,     0,    79,    59,     0,    85,    78,    76,
-       0,     0,     0,    80,     0,    62,     0,    60
+      30,    34,    54,     0,    55,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    73,    89,    41,     0,     0,
+      45,    64,    63,    81,    79,    61,    51,    52,   110,   111,
+     109,    70,    71,    69,    68,    66,    67,    65,   114,   113,
+     104,   105,   106,   107,   108,    37,    36,    38,    39,    35,
+      32,     0,   101,    56,     0,    92,    93,    94,    95,    96,
+      97,    42,    43,     0,     0,     0,     0,    59,    46,    84,
+      85,     0,    82,     0,     0,     0,    75,     0,    80,     0,
+       0,     0,    77,    57,     0,    83,    76,    74,     0,     0,
+       0,    78,     0,    60,     0,    58
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,     1,     5,     6,    23,    26,    32,     7,    14,    17,
-      19,    28,    29,    36,    37,    77,   120,   171,    69,   139,
-      70,    92,    72,   188,   211,   199,   197,   124,   203,   145,
-     186,   193,   194,    73,    74
+      19,    28,    29,    36,    37,    77,   120,   169,    69,   139,
+      70,    92,    72,   186,   209,   197,   195,   124,   201,   145,
+     184,   191,   192,    73,    74
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
@@ -770,146 +769,138 @@ static const yytype_int16 yydefgoto[] =
 #define YYPACT_NINF -66
 static const yytype_int16 yypact[] =
 {
-     -66,     6,   -66,   -59,     3,   -66,   -66,    59,   -66,   -66,
-     -66,    16,   -66,   -66,   -66,    28,    31,    -6,   -66,    82,
-      94,   -66,    42,   110,   113,    62,   117,    67,   113,   -66,
-     131,    76,    92,    -2,   -66,    93,   131,   -66,    78,   -66,
-     -66,   -66,   -66,   -66,    81,   -66,   -66,    -8,   -66,   102,
-     -66,   -66,   -66,   -66,   -66,   -66,   -66,   112,    90,    91,
-     104,   106,   109,   111,   -66,   -66,    78,   187,    78,   -42,
-     -66,    56,   -66,   135,   248,   -66,   -66,   164,   187,   114,
-     187,   187,    -7,   415,   187,   187,   187,   187,   187,   187,
-     -66,   -66,    56,   120,   215,   175,   187,    78,    78,    78,
-     -29,     5,   155,   187,   187,   187,   187,   187,   187,   187,
-     187,   187,   187,   187,   187,   187,   187,   187,   187,   187,
-      36,   -66,   415,   187,   -66,   381,   265,   166,   -29,   272,
-     294,   301,   323,   330,   352,   -66,   -66,   -66,   388,    33,
-      73,   151,   -66,   -66,   -66,   -66,   -66,   -66,   -66,   415,
-      96,    96,    96,   415,   415,   415,   415,   415,   415,   415,
-     -23,   -23,    25,    25,   -66,   -66,   -66,   -66,   -66,   -66,
-     -66,   -66,    36,   408,   -66,   -66,   129,   -66,   -66,   -66,
-     -66,   -66,   -66,   -66,   -66,    78,    -5,   132,   126,   -66,
-      73,   -66,   -66,    58,   -66,   187,   187,   137,   -66,   134,
-     -66,    -5,   359,    60,   408,   -66,    78,   -66,   -66,   -66,
-     187,   136,   -26,   415,    78,   -66,   -19,   -66
+     -66,     6,   -66,   -59,     0,   -66,   -66,    59,   -66,   -66,
+     -66,     9,   -66,   -66,   -66,   -44,    16,   -24,   -66,    49,
+      81,   -66,    26,    88,    92,    43,   115,    54,    92,   -66,
+     116,    63,    66,    -2,   -66,    75,   116,   -66,    79,   -66,
+     -66,   -66,   -66,   -66,    82,   -66,   -66,    -8,   -66,    83,
+     -66,   -66,   -66,   -66,   -66,   -66,   -66,   113,    72,    80,
+      84,    94,    96,    97,   -66,   -66,    79,   168,    79,   -42,
+     -66,    57,   -66,   125,   205,   -66,   -66,   137,   168,    98,
+     168,   168,    -7,   372,   168,   168,   168,   168,   168,   168,
+     -66,   -66,    57,   100,   169,   161,   168,    79,    79,    79,
+     -29,   156,   168,   168,   168,   168,   168,   168,   168,   168,
+     168,   168,   168,   168,   168,   168,   168,   168,   168,   168,
+      36,   -66,   372,   168,   -66,   338,   222,   149,   -29,   229,
+     251,   258,   280,   287,   309,   -66,   -66,   -66,   345,    34,
+      74,   135,   -66,   -66,   -66,   -66,   -66,   372,   104,   104,
+     104,   372,   372,   372,   372,   372,   372,   372,   -23,   -23,
+      25,    25,   -66,   -66,   -66,   -66,   -66,   -66,   -66,   -66,
+      36,   365,   -66,   -66,   120,   -66,   -66,   -66,   -66,   -66,
+     -66,   -66,   -66,    79,    -5,   119,   110,   -66,    74,   -66,
+     -66,    60,   -66,   168,   168,   122,   -66,   118,   -66,    -5,
+     316,    62,   365,   -66,    79,   -66,   -66,   -66,   168,   123,
+     -26,   372,    79,   -66,   -19,   -66
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-     -66,   -66,   -66,   203,   -66,   -66,   -66,   -66,   -66,   -66,
-     -66,   -66,   180,   -66,   173,   -66,    95,   -66,   -66,   -66,
-     123,   -38,   -65,   -66,   -66,   -66,   -66,    24,   -66,    85,
-     -66,   -66,    13,   158,   -37
+     -66,   -66,   -66,   187,   -66,   -66,   -66,   -66,   -66,   -66,
+     -66,   -66,   165,   -66,   159,   -66,    77,   -66,   -66,   -66,
+      95,   -38,   -65,   -66,   -66,   -66,   -66,    19,   -66,   103,
+     -66,   -66,    10,   151,   -37
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
    number is the opposite.  If zero, do what YYDEFACT says.
    If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -89
+#define YYTABLE_NINF -87
 static const yytype_int16 yytable[] =
 {
-      71,   143,   127,    93,     8,   191,     2,     3,   192,   -14,
-     -14,   -14,    40,    41,    78,   146,    98,    99,    10,    79,
-      83,   128,    52,    98,    99,    15,    95,    96,    90,    97,
+      71,   143,   127,    93,     8,   189,     2,     3,   190,   -14,
+     -14,   -14,    40,    41,    78,    10,    98,    99,    15,    79,
+      83,   128,    16,    98,    99,    18,    95,    96,    90,    97,
       91,    94,   140,   115,   116,   117,   118,   119,    42,    43,
-      18,   122,   144,   125,   126,     4,   215,   129,   130,   131,
-     132,   133,   134,   217,   167,   168,   169,   170,    20,   138,
-     141,   142,    11,    12,    13,   149,   150,   151,   152,   153,
-     154,   155,   156,   157,   158,   159,   160,   161,   162,   163,
-     164,   165,   166,   117,   118,   119,   173,    46,    47,    48,
-      49,    21,    50,    51,    16,    52,    75,    76,    98,    99,
-      22,    53,    54,    55,    56,   184,   185,    57,    24,    58,
-      59,    60,    61,    62,    63,   -48,   -48,    25,    64,    65,
-     190,    46,    27,    48,    49,    31,    50,    51,    30,    52,
-     200,   201,   209,   210,    33,    53,    54,    55,    56,    66,
-      67,    35,    38,    58,    59,    60,    61,    62,    63,    68,
-     113,   114,   115,   116,   117,   118,   119,    39,   202,   204,
-      44,    84,    85,   100,    46,   148,    48,    49,   212,    50,
-      51,    80,    52,   213,    67,    86,   216,    87,    53,    54,
-      88,   121,    89,    81,   137,   123,    58,    59,    60,    61,
-      62,    63,   135,   175,    99,   189,    46,   196,    48,    49,
-     195,    50,    51,   205,    52,   206,     9,   214,    34,    45,
-      53,    54,   198,   176,   207,    82,   172,    67,    58,    59,
-      60,    61,    62,    63,   147,     0,    81,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   -88,     0,     0,     0,     0,     0,    67,
-       0,     0,   101,   102,     0,     0,     0,     0,    81,   103,
+      20,   122,   144,   125,   126,     4,   213,   129,   130,   131,
+     132,   133,   134,   215,   165,   166,   167,   168,    21,   138,
+     141,   142,    11,    12,    13,   147,   148,   149,   150,   151,
+     152,   153,   154,   155,   156,   157,   158,   159,   160,   161,
+     162,   163,   164,   117,   118,   119,   171,    22,    46,    47,
+      48,    49,    24,    50,    51,    25,    52,    75,    76,    98,
+      99,    27,    53,    54,    55,    56,   182,   183,    57,    30,
+      58,    59,    60,    61,    62,    63,   -48,   -48,   188,    64,
+      65,    33,    46,    31,    48,    49,    35,    50,    51,    38,
+      52,    39,   198,   199,   207,   208,    53,    54,    55,    56,
+      66,    67,    44,    84,    58,    59,    60,    61,    62,    63,
+      68,    85,    80,   100,   121,    86,   200,   202,   113,   114,
+     115,   116,   117,   118,   119,    87,   210,    88,    89,   123,
+     137,   211,   135,    52,   214,    67,   173,    46,    99,    48,
+      49,   194,    50,    51,    81,    52,   187,   193,   203,   204,
+       9,    53,    54,    34,   212,    45,   146,   -86,   170,    58,
+      59,    60,    61,    62,    63,   196,   101,   102,    82,   205,
+       0,     0,     0,   103,   104,   105,   106,   107,   108,   109,
+     110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
+      67,   174,     0,   -86,     0,     0,     0,     0,     0,    81,
+       0,   136,   101,   102,     0,     0,     0,     0,     0,   103,
      104,   105,   106,   107,   108,   109,   110,   111,   112,   113,
-     114,   115,   116,   117,   118,   119,   -88,     0,     0,     0,
-       0,     0,     0,     0,     0,   101,   102,   136,     0,     0,
-       0,     0,   103,   104,   105,   106,   107,   108,   109,   110,
-     111,   112,   113,   114,   115,   116,   117,   118,   119,   103,
-     104,   105,     0,     0,     0,     0,   103,   104,   105,   113,
-     114,   115,   116,   117,   118,   119,   113,   114,   115,   116,
-     117,   118,   119,     0,     0,     0,     0,   136,   103,   104,
-     105,     0,     0,     0,   177,   103,   104,   105,   113,   114,
-     115,   116,   117,   118,   119,   113,   114,   115,   116,   117,
-     118,   119,     0,     0,     0,     0,   178,   103,   104,   105,
-       0,     0,     0,   179,   103,   104,   105,   113,   114,   115,
-     116,   117,   118,   119,   113,   114,   115,   116,   117,   118,
-     119,     0,     0,     0,     0,   180,   103,   104,   105,     0,
-       0,     0,   181,   103,   104,   105,   113,   114,   115,   116,
+     114,   115,   116,   117,   118,   119,   103,   104,   105,     0,
+       0,     0,     0,   103,   104,   105,   113,   114,   115,   116,
      117,   118,   119,   113,   114,   115,   116,   117,   118,   119,
-       0,     0,     0,     0,   182,   103,   104,   105,     0,     0,
-       0,   208,   103,   104,   105,   113,   114,   115,   116,   117,
+       0,     0,     0,     0,   136,   103,   104,   105,     0,     0,
+       0,   175,   103,   104,   105,   113,   114,   115,   116,   117,
      118,   119,   113,   114,   115,   116,   117,   118,   119,     0,
-       0,   174,   103,   104,   105,     0,     0,     0,   183,   103,
+       0,     0,     0,   176,   103,   104,   105,     0,     0,     0,
+     177,   103,   104,   105,   113,   114,   115,   116,   117,   118,
+     119,   113,   114,   115,   116,   117,   118,   119,     0,     0,
+       0,     0,   178,   103,   104,   105,     0,     0,     0,   179,
+     103,   104,   105,   113,   114,   115,   116,   117,   118,   119,
+     113,   114,   115,   116,   117,   118,   119,     0,     0,     0,
+       0,   180,   103,   104,   105,     0,     0,     0,   206,   103,
      104,   105,   113,   114,   115,   116,   117,   118,   119,   113,
-     114,   115,   116,   117,   118,   119,   187
+     114,   115,   116,   117,   118,   119,     0,     0,   172,   103,
+     104,   105,     0,     0,     0,   181,   103,   104,   105,   113,
+     114,   115,   116,   117,   118,   119,   113,   114,   115,   116,
+     117,   118,   119,   185
 };
 
 static const yytype_int16 yycheck[] =
 {
       38,    30,     9,    68,    63,    10,     0,     1,    13,     3,
-       4,     5,    14,    15,    22,    10,    42,    43,    15,    27,
-      57,    28,    17,    42,    43,     9,    68,    69,    66,    71,
+       4,     5,    14,    15,    22,    15,    42,    43,     9,    27,
+      57,    28,    66,    42,    43,     9,    68,    69,    66,    71,
       67,    68,    97,    56,    57,    58,    59,    60,    40,    41,
-       9,    78,    71,    80,    81,    39,    72,    84,    85,    86,
-      87,    88,    89,    72,    18,    19,    20,    21,    64,    96,
+      64,    78,    71,    80,    81,    39,    72,    84,    85,    86,
+      87,    88,    89,    72,    18,    19,    20,    21,     9,    96,
       98,    99,     3,     4,     5,   102,   103,   104,   105,   106,
      107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
-     117,   118,   119,    58,    59,    60,   123,     9,    10,    11,
-      12,     9,    14,    15,    66,    17,    15,    16,    42,    43,
-       6,    23,    24,    25,    26,    72,    73,    29,    66,    31,
-      32,    33,    34,    35,    36,    42,    43,     7,    40,    41,
-     185,     9,     9,    11,    12,     8,    14,    15,    66,    17,
-      72,    73,    72,    73,    67,    23,    24,    25,    26,    61,
-      62,    10,    66,    31,    32,    33,    34,    35,    36,    71,
-      54,    55,    56,    57,    58,    59,    60,    65,   195,   196,
-      67,    71,    71,    28,     9,    10,    11,    12,   206,    14,
-      15,    69,    17,   210,    62,    71,   214,    71,    23,    24,
-      71,    17,    71,    71,     9,    71,    31,    32,    33,    34,
-      35,    36,    72,    27,    43,    66,     9,    71,    11,    12,
-      68,    14,    15,    66,    17,    71,     3,    71,    28,    36,
-      23,    24,   188,   128,   201,    57,   121,    62,    31,    32,
-      33,    34,    35,    36,   101,    -1,    71,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    28,    -1,    -1,    -1,    -1,    -1,    62,
-      -1,    -1,    37,    38,    -1,    -1,    -1,    -1,    71,    44,
+     117,   118,   119,    58,    59,    60,   123,     6,     9,    10,
+      11,    12,    66,    14,    15,     7,    17,    15,    16,    42,
+      43,     9,    23,    24,    25,    26,    72,    73,    29,    66,
+      31,    32,    33,    34,    35,    36,    42,    43,   183,    40,
+      41,    67,     9,     8,    11,    12,    10,    14,    15,    66,
+      17,    65,    72,    73,    72,    73,    23,    24,    25,    26,
+      61,    62,    67,    71,    31,    32,    33,    34,    35,    36,
+      71,    71,    69,    28,    17,    71,   193,   194,    54,    55,
+      56,    57,    58,    59,    60,    71,   204,    71,    71,    71,
+       9,   208,    72,    17,   212,    62,    27,     9,    43,    11,
+      12,    71,    14,    15,    71,    17,    66,    68,    66,    71,
+       3,    23,    24,    28,    71,    36,   101,    28,   121,    31,
+      32,    33,    34,    35,    36,   186,    37,    38,    57,   199,
+      -1,    -1,    -1,    44,    45,    46,    47,    48,    49,    50,
+      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
+      62,   128,    -1,    28,    -1,    -1,    -1,    -1,    -1,    71,
+      -1,    72,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
       45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
-      55,    56,    57,    58,    59,    60,    28,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    37,    38,    72,    -1,    -1,
-      -1,    -1,    44,    45,    46,    47,    48,    49,    50,    51,
-      52,    53,    54,    55,    56,    57,    58,    59,    60,    44,
-      45,    46,    -1,    -1,    -1,    -1,    44,    45,    46,    54,
-      55,    56,    57,    58,    59,    60,    54,    55,    56,    57,
-      58,    59,    60,    -1,    -1,    -1,    -1,    72,    44,    45,
-      46,    -1,    -1,    -1,    72,    44,    45,    46,    54,    55,
-      56,    57,    58,    59,    60,    54,    55,    56,    57,    58,
-      59,    60,    -1,    -1,    -1,    -1,    72,    44,    45,    46,
-      -1,    -1,    -1,    72,    44,    45,    46,    54,    55,    56,
-      57,    58,    59,    60,    54,    55,    56,    57,    58,    59,
-      60,    -1,    -1,    -1,    -1,    72,    44,    45,    46,    -1,
-      -1,    -1,    72,    44,    45,    46,    54,    55,    56,    57,
+      55,    56,    57,    58,    59,    60,    44,    45,    46,    -1,
+      -1,    -1,    -1,    44,    45,    46,    54,    55,    56,    57,
       58,    59,    60,    54,    55,    56,    57,    58,    59,    60,
       -1,    -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,
       -1,    72,    44,    45,    46,    54,    55,    56,    57,    58,
       59,    60,    54,    55,    56,    57,    58,    59,    60,    -1,
-      -1,    70,    44,    45,    46,    -1,    -1,    -1,    70,    44,
+      -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,    -1,
+      72,    44,    45,    46,    54,    55,    56,    57,    58,    59,
+      60,    54,    55,    56,    57,    58,    59,    60,    -1,    -1,
+      -1,    -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,
+      44,    45,    46,    54,    55,    56,    57,    58,    59,    60,
+      54,    55,    56,    57,    58,    59,    60,    -1,    -1,    -1,
+      -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,    44,
       45,    46,    54,    55,    56,    57,    58,    59,    60,    54,
-      55,    56,    57,    58,    59,    60,    68
+      55,    56,    57,    58,    59,    60,    -1,    -1,    70,    44,
+      45,    46,    -1,    -1,    -1,    70,    44,    45,    46,    54,
+      55,    56,    57,    58,    59,    60,    54,    55,    56,    57,
+      58,    59,    60,    68
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -930,14 +921,14 @@ static const yytype_uint8 yystos[] =
       51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
       90,    17,   108,    71,   101,   108,   108,     9,    28,   108,
      108,   108,   108,   108,   108,    72,    72,     9,   108,    93,
-      96,    95,    95,    30,    71,   103,    10,    94,    10,   108,
+      96,    95,    95,    30,    71,   103,    94,   108,   108,   108,
      108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
-     108,   108,   108,   108,   108,   108,   108,    18,    19,    20,
-      21,    91,    90,   108,    70,    27,   103,    72,    72,    72,
-      72,    72,    72,    70,    72,    73,   104,    68,    97,    66,
-      96,    10,    13,   105,   106,    68,    71,   100,   101,    99,
-      72,    73,   108,   102,   108,    66,    71,   106,    72,    72,
-      73,    98,    95,   108,    71,    72,    95,    72
+     108,   108,   108,   108,   108,    18,    19,    20,    21,    91,
+      90,   108,    70,    27,   103,    72,    72,    72,    72,    72,
+      72,    70,    72,    73,   104,    68,    97,    66,    96,    10,
+      13,   105,   106,    68,    71,   100,   101,    99,    72,    73,
+     108,   102,   108,    66,    71,   106,    72,    72,    73,    98,
+      95,   108,    71,    72,    95,    72
 };
 
 #define yyerrok		(yyerrstatus = 0)
@@ -1460,42 +1451,42 @@ yydestruct (yymsg, yytype, yyvaluep, yyscanner, compiler)
       case 9: /* "_IDENTIFIER_" */
 #line 178 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1464 "grammar.c"
+#line 1455 "grammar.c"
 	break;
       case 10: /* "_STRING_IDENTIFIER_" */
 #line 179 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1469 "grammar.c"
+#line 1460 "grammar.c"
 	break;
       case 11: /* "_STRING_COUNT_" */
 #line 180 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1474 "grammar.c"
+#line 1465 "grammar.c"
 	break;
       case 12: /* "_STRING_OFFSET_" */
 #line 181 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1479 "grammar.c"
+#line 1470 "grammar.c"
 	break;
       case 13: /* "_STRING_IDENTIFIER_WITH_WILDCARD_" */
 #line 182 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1484 "grammar.c"
+#line 1475 "grammar.c"
 	break;
       case 15: /* "_TEXT_STRING_" */
 #line 183 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1489 "grammar.c"
+#line 1480 "grammar.c"
 	break;
       case 16: /* "_HEX_STRING_" */
 #line 184 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1494 "grammar.c"
+#line 1485 "grammar.c"
 	break;
       case 17: /* "_REGEXP_" */
 #line 185 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1499 "grammar.c"
+#line 1490 "grammar.c"
 	break;
 
       default:
@@ -2517,7 +2508,7 @@ yyreduce:
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_TO_BOOL,
+              OP_STR_TO_BOOL,
               NULL);
 
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
@@ -2589,48 +2580,10 @@ yyreduce:
   case 53:
 #line 922 "grammar.y"
     {
-        CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_STRING, "contains");
-
-        int result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(3) - (3)].c_string),
-            OP_CONTAINS_STR,
-            UNDEFINED);
-
-        yr_free((yyvsp[(3) - (3)].c_string));
-
-        ERROR_IF(result != ERROR_SUCCESS);
-
-        (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
-      }
-    break;
-
-  case 54:
-#line 938 "grammar.y"
-    {
-        CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_STRING, "matches");
-
-        int result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(3) - (3)].c_string),
-            OP_MATCHES_STR,
-            UNDEFINED);
-
-        yr_free((yyvsp[(3) - (3)].c_string));
-
-        ERROR_IF(result != ERROR_SUCCESS);
-
-        (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
-      }
-    break;
-
-  case 55:
-#line 954 "grammar.y"
-    {
         int result = yr_parser_reduce_string_identifier(
             yyscanner,
             (yyvsp[(1) - (1)].c_string),
-            OP_STR_FOUND,
+            OP_FOUND,
             UNDEFINED);
 
         yr_free((yyvsp[(1) - (1)].c_string));
@@ -2641,15 +2594,15 @@ yyreduce:
       }
     break;
 
-  case 56:
-#line 968 "grammar.y"
+  case 54:
+#line 936 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "at");
 
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             (yyvsp[(1) - (3)].c_string),
-            OP_STR_FOUND_AT,
+            OP_FOUND_AT,
             (yyvsp[(3) - (3)].expression).value.integer);
 
         yr_free((yyvsp[(1) - (3)].c_string));
@@ -2660,13 +2613,13 @@ yyreduce:
       }
     break;
 
-  case 57:
-#line 984 "grammar.y"
+  case 55:
+#line 952 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             (yyvsp[(1) - (3)].c_string),
-            OP_STR_FOUND_IN,
+            OP_FOUND_IN,
             UNDEFINED);
 
         yr_free((yyvsp[(1) - (3)].c_string));
@@ -2677,8 +2630,8 @@ yyreduce:
       }
     break;
 
-  case 58:
-#line 998 "grammar.y"
+  case 56:
+#line 966 "grammar.y"
     {
         int var_index;
 
@@ -2715,8 +2668,8 @@ yyreduce:
       }
     break;
 
-  case 59:
-#line 1033 "grammar.y"
+  case 57:
+#line 1001 "grammar.y"
     {
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
         int8_t* addr;
@@ -2753,8 +2706,8 @@ yyreduce:
       }
     break;
 
-  case 60:
-#line 1068 "grammar.y"
+  case 58:
+#line 1036 "grammar.y"
     {
         int mem_offset;
 
@@ -2832,8 +2785,8 @@ yyreduce:
       }
     break;
 
-  case 61:
-#line 1144 "grammar.y"
+  case 59:
+#line 1112 "grammar.y"
     {
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
         int8_t* addr;
@@ -2865,8 +2818,8 @@ yyreduce:
       }
     break;
 
-  case 62:
-#line 1174 "grammar.y"
+  case 60:
+#line 1142 "grammar.y"
     {
         int mem_offset;
 
@@ -2915,8 +2868,8 @@ yyreduce:
       }
     break;
 
-  case 63:
-#line 1221 "grammar.y"
+  case 61:
+#line 1189 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_OF, NULL);
 
@@ -2924,8 +2877,8 @@ yyreduce:
       }
     break;
 
-  case 64:
-#line 1227 "grammar.y"
+  case 62:
+#line 1195 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_NOT, NULL);
 
@@ -2933,8 +2886,8 @@ yyreduce:
       }
     break;
 
-  case 65:
-#line 1233 "grammar.y"
+  case 63:
+#line 1201 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_AND, NULL);
 
@@ -2942,8 +2895,8 @@ yyreduce:
       }
     break;
 
-  case 66:
-#line 1239 "grammar.y"
+  case 64:
+#line 1207 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_BOOLEAN, "or");
 
@@ -2953,8 +2906,8 @@ yyreduce:
       }
     break;
 
-  case 67:
-#line 1247 "grammar.y"
+  case 65:
+#line 1215 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<");
@@ -2965,8 +2918,8 @@ yyreduce:
       }
     break;
 
-  case 68:
-#line 1256 "grammar.y"
+  case 66:
+#line 1224 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">");
@@ -2977,8 +2930,8 @@ yyreduce:
       }
     break;
 
-  case 69:
-#line 1265 "grammar.y"
+  case 67:
+#line 1233 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<=");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<=");
@@ -2989,8 +2942,8 @@ yyreduce:
       }
     break;
 
-  case 70:
-#line 1274 "grammar.y"
+  case 68:
+#line 1242 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">=");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">=");
@@ -3001,8 +2954,8 @@ yyreduce:
       }
     break;
 
-  case 71:
-#line 1283 "grammar.y"
+  case 69:
+#line 1251 "grammar.y"
     {
         if ((yyvsp[(1) - (3)].expression).type != (yyvsp[(3) - (3)].expression).type)
         {
@@ -3014,7 +2967,7 @@ yyreduce:
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_EQ,
+              OP_STR_EQ,
               NULL);
         }
         else
@@ -3031,8 +2984,8 @@ yyreduce:
       }
     break;
 
-  case 72:
-#line 1310 "grammar.y"
+  case 70:
+#line 1278 "grammar.y"
     {
         if ((yyvsp[(1) - (3)].expression).type != (yyvsp[(3) - (3)].expression).type)
         {
@@ -3044,7 +2997,7 @@ yyreduce:
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_EQ,
+              OP_STR_EQ,
               NULL);
         }
         else
@@ -3061,8 +3014,8 @@ yyreduce:
       }
     break;
 
-  case 73:
-#line 1337 "grammar.y"
+  case 71:
+#line 1305 "grammar.y"
     {
         if ((yyvsp[(1) - (3)].expression).type != (yyvsp[(3) - (3)].expression).type)
         {
@@ -3074,7 +3027,7 @@ yyreduce:
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_NEQ,
+              OP_STR_NEQ,
               NULL);
         }
         else
@@ -3091,32 +3044,32 @@ yyreduce:
       }
     break;
 
-  case 74:
-#line 1364 "grammar.y"
+  case 72:
+#line 1332 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(1) - (1)].expression);
       }
     break;
 
-  case 75:
-#line 1368 "grammar.y"
+  case 73:
+#line 1336 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(2) - (3)].expression);
       }
     break;
 
-  case 76:
-#line 1375 "grammar.y"
+  case 74:
+#line 1343 "grammar.y"
     { (yyval.integer) = INTEGER_SET_ENUMERATION; }
     break;
 
-  case 77:
-#line 1376 "grammar.y"
+  case 75:
+#line 1344 "grammar.y"
     { (yyval.integer) = INTEGER_SET_RANGE; }
     break;
 
-  case 78:
-#line 1382 "grammar.y"
+  case 76:
+#line 1350 "grammar.y"
     {
         if ((yyvsp[(2) - (6)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3136,8 +3089,8 @@ yyreduce:
       }
     break;
 
-  case 79:
-#line 1404 "grammar.y"
+  case 77:
+#line 1372 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3151,8 +3104,8 @@ yyreduce:
       }
     break;
 
-  case 80:
-#line 1416 "grammar.y"
+  case 78:
+#line 1384 "grammar.y"
     {
         if ((yyvsp[(3) - (3)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3165,61 +3118,61 @@ yyreduce:
       }
     break;
 
-  case 81:
-#line 1431 "grammar.y"
+  case 79:
+#line 1399 "grammar.y"
     {
         // Push end-of-list marker
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
       }
     break;
 
-  case 83:
-#line 1437 "grammar.y"
+  case 81:
+#line 1405 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
         yr_parser_emit_pushes_for_strings(yyscanner, "$*");
       }
     break;
 
-  case 86:
-#line 1452 "grammar.y"
+  case 84:
+#line 1420 "grammar.y"
     {
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
         yr_free((yyvsp[(1) - (1)].c_string));
       }
     break;
 
-  case 87:
-#line 1457 "grammar.y"
+  case 85:
+#line 1425 "grammar.y"
     {
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
         yr_free((yyvsp[(1) - (1)].c_string));
       }
     break;
 
-  case 89:
-#line 1467 "grammar.y"
+  case 87:
+#line 1435 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
       }
     break;
 
-  case 90:
-#line 1471 "grammar.y"
+  case 88:
+#line 1439 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL);
       }
     break;
 
-  case 91:
-#line 1479 "grammar.y"
+  case 89:
+#line 1447 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(2) - (3)].expression);
       }
     break;
 
-  case 92:
-#line 1483 "grammar.y"
+  case 90:
+#line 1451 "grammar.y"
     {
         compiler->last_result = yr_parser_emit(
             yyscanner, OP_FILESIZE, NULL);
@@ -3231,8 +3184,8 @@ yyreduce:
       }
     break;
 
-  case 93:
-#line 1493 "grammar.y"
+  case 91:
+#line 1461 "grammar.y"
     {
         yywarning(yyscanner,
             "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead.");
@@ -3247,8 +3200,8 @@ yyreduce:
       }
     break;
 
-  case 94:
-#line 1506 "grammar.y"
+  case 92:
+#line 1474 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "int8");
 
@@ -3262,8 +3215,8 @@ yyreduce:
       }
     break;
 
-  case 95:
-#line 1518 "grammar.y"
+  case 93:
+#line 1486 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "int16");
 
@@ -3277,8 +3230,8 @@ yyreduce:
       }
     break;
 
-  case 96:
-#line 1530 "grammar.y"
+  case 94:
+#line 1498 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "int32");
 
@@ -3292,8 +3245,8 @@ yyreduce:
       }
     break;
 
-  case 97:
-#line 1542 "grammar.y"
+  case 95:
+#line 1510 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "uint8");
 
@@ -3307,8 +3260,8 @@ yyreduce:
       }
     break;
 
-  case 98:
-#line 1554 "grammar.y"
+  case 96:
+#line 1522 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "uint16");
 
@@ -3322,8 +3275,8 @@ yyreduce:
       }
     break;
 
-  case 99:
-#line 1566 "grammar.y"
+  case 97:
+#line 1534 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "uint32");
 
@@ -3337,8 +3290,8 @@ yyreduce:
       }
     break;
 
-  case 100:
-#line 1578 "grammar.y"
+  case 98:
+#line 1546 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner, OP_PUSH, (yyvsp[(1) - (1)].integer), NULL);
@@ -3350,16 +3303,16 @@ yyreduce:
       }
     break;
 
-  case 101:
-#line 1588 "grammar.y"
+  case 99:
+#line 1556 "grammar.y"
     {
-        SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
-        char* string;
+        SIZED_STRING* sized_string;
 
-        compiler->last_result = yr_arena_write_string(
+        compiler->last_result = yr_arena_write_data(
             compiler->sz_arena,
-            sized_string->c_string,
-            &string);
+            (yyvsp[(1) - (1)].sized_string),
+            (yyvsp[(1) - (1)].sized_string)->length + sizeof(SIZED_STRING),
+            (void*) &sized_string);
 
         yr_free((yyvsp[(1) - (1)].sized_string));
 
@@ -3367,7 +3320,7 @@ yyreduce:
           compiler->last_result = yr_parser_emit_with_arg_reloc(
               yyscanner,
               OP_PUSH,
-              PTR_TO_UINT64(string),
+              PTR_TO_UINT64(sized_string),
               NULL);
 
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
@@ -3376,13 +3329,13 @@ yyreduce:
       }
     break;
 
-  case 102:
-#line 1611 "grammar.y"
+  case 100:
+#line 1579 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             (yyvsp[(1) - (1)].c_string),
-            OP_STR_COUNT,
+            OP_COUNT,
             UNDEFINED);
 
         yr_free((yyvsp[(1) - (1)].c_string));
@@ -3394,13 +3347,13 @@ yyreduce:
       }
     break;
 
-  case 103:
-#line 1626 "grammar.y"
+  case 101:
+#line 1594 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             (yyvsp[(1) - (4)].c_string),
-            OP_STR_OFFSET,
+            OP_OFFSET,
             UNDEFINED);
 
         yr_free((yyvsp[(1) - (4)].c_string));
@@ -3412,8 +3365,8 @@ yyreduce:
       }
     break;
 
-  case 104:
-#line 1641 "grammar.y"
+  case 102:
+#line 1609 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner,
@@ -3425,7 +3378,7 @@ yyreduce:
           compiler->last_result = yr_parser_reduce_string_identifier(
               yyscanner,
               (yyvsp[(1) - (1)].c_string),
-              OP_STR_OFFSET,
+              OP_OFFSET,
               UNDEFINED);
 
         yr_free((yyvsp[(1) - (1)].c_string));
@@ -3437,8 +3390,8 @@ yyreduce:
       }
     break;
 
-  case 105:
-#line 1663 "grammar.y"
+  case 103:
+#line 1631 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -1)  // loop identifier
         {
@@ -3477,8 +3430,8 @@ yyreduce:
       }
     break;
 
-  case 106:
-#line 1700 "grammar.y"
+  case 104:
+#line 1668 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "+");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "+");
@@ -3490,8 +3443,8 @@ yyreduce:
       }
     break;
 
-  case 107:
-#line 1710 "grammar.y"
+  case 105:
+#line 1678 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "-");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "-");
@@ -3503,8 +3456,8 @@ yyreduce:
       }
     break;
 
-  case 108:
-#line 1720 "grammar.y"
+  case 106:
+#line 1688 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "*");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "*");
@@ -3516,8 +3469,8 @@ yyreduce:
       }
     break;
 
-  case 109:
-#line 1730 "grammar.y"
+  case 107:
+#line 1698 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "\\");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "\\");
@@ -3529,8 +3482,8 @@ yyreduce:
       }
     break;
 
-  case 110:
-#line 1740 "grammar.y"
+  case 108:
+#line 1708 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "%");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "%");
@@ -3542,8 +3495,8 @@ yyreduce:
       }
     break;
 
-  case 111:
-#line 1750 "grammar.y"
+  case 109:
+#line 1718 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
@@ -3555,8 +3508,8 @@ yyreduce:
       }
     break;
 
-  case 112:
-#line 1760 "grammar.y"
+  case 110:
+#line 1728 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
@@ -3568,8 +3521,8 @@ yyreduce:
       }
     break;
 
-  case 113:
-#line 1770 "grammar.y"
+  case 111:
+#line 1738 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "|");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "|");
@@ -3581,8 +3534,8 @@ yyreduce:
       }
     break;
 
-  case 114:
-#line 1780 "grammar.y"
+  case 112:
+#line 1748 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(2) - (2)].expression), EXPRESSION_TYPE_INTEGER, "~");
 
@@ -3594,8 +3547,8 @@ yyreduce:
       }
     break;
 
-  case 115:
-#line 1790 "grammar.y"
+  case 113:
+#line 1758 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<<");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<<");
@@ -3607,8 +3560,8 @@ yyreduce:
       }
     break;
 
-  case 116:
-#line 1800 "grammar.y"
+  case 114:
+#line 1768 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">>");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">>");
@@ -3620,8 +3573,8 @@ yyreduce:
       }
     break;
 
-  case 117:
-#line 1810 "grammar.y"
+  case 115:
+#line 1778 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(1) - (1)].expression);
       }
@@ -3629,7 +3582,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 3633 "grammar.c"
+#line 3586 "grammar.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3843,6 +3796,6 @@ yyreturn:
 }
 
 
-#line 1815 "grammar.y"
+#line 1783 "grammar.y"
 
 
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 0d3bedf..715af05 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -860,7 +860,7 @@ boolean_expression
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_TO_BOOL,
+              OP_STR_TO_BOOL,
               NULL);
 
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
@@ -918,44 +918,12 @@ expression
 
         $$.type = EXPRESSION_TYPE_BOOLEAN;
       }
-    | primary_expression _CONTAINS_ _STRING_IDENTIFIER_
-      {
-        CHECK_TYPE($1, EXPRESSION_TYPE_STRING, "contains");
-
-        int result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $3,
-            OP_CONTAINS_STR,
-            UNDEFINED);
-
-        yr_free($3);
-
-        ERROR_IF(result != ERROR_SUCCESS);
-
-        $$.type = EXPRESSION_TYPE_BOOLEAN;
-      }
-    | primary_expression _MATCHES_ _STRING_IDENTIFIER_
-      {
-        CHECK_TYPE($1, EXPRESSION_TYPE_STRING, "matches");
-
-        int result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $3,
-            OP_MATCHES_STR,
-            UNDEFINED);
-
-        yr_free($3);
-
-        ERROR_IF(result != ERROR_SUCCESS);
-
-        $$.type = EXPRESSION_TYPE_BOOLEAN;
-      }
     | _STRING_IDENTIFIER_
       {
         int result = yr_parser_reduce_string_identifier(
             yyscanner,
             $1,
-            OP_STR_FOUND,
+            OP_FOUND,
             UNDEFINED);
 
         yr_free($1);
@@ -971,7 +939,7 @@ expression
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             $1,
-            OP_STR_FOUND_AT,
+            OP_FOUND_AT,
             $3.value.integer);
 
         yr_free($1);
@@ -985,7 +953,7 @@ expression
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             $1,
-            OP_STR_FOUND_IN,
+            OP_FOUND_IN,
             UNDEFINED);
 
         yr_free($1);
@@ -1291,7 +1259,7 @@ expression
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_EQ,
+              OP_STR_EQ,
               NULL);
         }
         else
@@ -1318,7 +1286,7 @@ expression
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_EQ,
+              OP_STR_EQ,
               NULL);
         }
         else
@@ -1345,7 +1313,7 @@ expression
         {
           compiler->last_result = yr_parser_emit(
               yyscanner,
-              OP_SZ_NEQ,
+              OP_STR_NEQ,
               NULL);
         }
         else
@@ -1586,13 +1554,13 @@ primary_expression
       }
     | _TEXT_STRING_
       {
-        SIZED_STRING* sized_string = $1;
-        char* string;
+        SIZED_STRING* sized_string;
 
-        compiler->last_result = yr_arena_write_string(
+        compiler->last_result = yr_arena_write_data(
             compiler->sz_arena,
-            sized_string->c_string,
-            &string);
+            $1,
+            $1->length + sizeof(SIZED_STRING),
+            (void*) &sized_string);
 
         yr_free($1);
 
@@ -1600,7 +1568,7 @@ primary_expression
           compiler->last_result = yr_parser_emit_with_arg_reloc(
               yyscanner,
               OP_PUSH,
-              PTR_TO_UINT64(string),
+              PTR_TO_UINT64(sized_string),
               NULL);
 
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
@@ -1612,7 +1580,7 @@ primary_expression
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             $1,
-            OP_STR_COUNT,
+            OP_COUNT,
             UNDEFINED);
 
         yr_free($1);
@@ -1627,7 +1595,7 @@ primary_expression
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
             $1,
-            OP_STR_OFFSET,
+            OP_OFFSET,
             UNDEFINED);
 
         yr_free($1);
@@ -1649,7 +1617,7 @@ primary_expression
           compiler->last_result = yr_parser_reduce_string_identifier(
               yyscanner,
               $1,
-              OP_STR_OFFSET,
+              OP_OFFSET,
               UNDEFINED);
 
         yr_free($1);
diff --git a/libyara/include/yara/exec.h b/libyara/include/yara/exec.h
index e3ea9e0..47ef915 100644
--- a/libyara/include/yara/exec.h
+++ b/libyara/include/yara/exec.h
@@ -37,9 +37,9 @@ limitations under the License.
 #define OP_GE             7
 #define OP_EQ             8
 #define OP_NEQ            9
-#define OP_SZ_EQ          10
-#define OP_SZ_NEQ         11
-#define OP_SZ_TO_BOOL     12
+#define OP_STR_EQ         10
+#define OP_STR_NEQ        11
+#define OP_STR_TO_BOOL    12
 #define OP_ADD            13
 #define OP_SUB            14
 #define OP_MUL            15
@@ -58,11 +58,11 @@ limitations under the License.
 #define OP_OBJ_VALUE      28
 #define OP_OBJ_FIELD      29
 #define OP_INDEX_ARRAY    30
-#define OP_STR_COUNT      31
-#define OP_STR_FOUND      32
-#define OP_STR_FOUND_AT   33
-#define OP_STR_FOUND_IN   34
-#define OP_STR_OFFSET     35
+#define OP_COUNT          31
+#define OP_FOUND          32
+#define OP_FOUND_AT       33
+#define OP_FOUND_IN       34
+#define OP_OFFSET         35
 #define OP_OF             36
 #define OP_PUSH_RULE      37
 #define OP_MATCH_RULE     38
@@ -86,8 +86,6 @@ limitations under the License.
 #define OP_MATCHES        56
 #define OP_IMPORT         57
 #define OP_LOOKUP_DICT    58
-#define OP_CONTAINS_STR   59
-#define OP_MATCHES_STR    60
 
 
 #define OPERATION(operator, op1, op2) \
diff --git a/libyara/include/yara/modules.h b/libyara/include/yara/modules.h
index 8874f7a..cdad1fc 100644
--- a/libyara/include/yara/modules.h
+++ b/libyara/include/yara/modules.h
@@ -281,6 +281,7 @@ limitations under the License.
       char* s = (char*) (string); \
       yr_object_set_string( \
           (s != (char*) UNDEFINED) ? s : NULL, \
+          (s != (char*) UNDEFINED) ? strlen(s) : 0, \
           __function_obj->return_obj, \
           NULL); \
       return ERROR_SUCCESS; \
diff --git a/libyara/modules/tests.c b/libyara/modules/tests.c
index 0aaae57..af11277 100644
--- a/libyara/modules/tests.c
+++ b/libyara/modules/tests.c
@@ -105,7 +105,8 @@ int module_load(
   set_string("foo", module_object, "string_array[%i]", 0);
   set_string("bar", module_object, "string_array[%i]", 1);
   set_string("baz", module_object, "string_array[%i]", 2);
-  set_sized_string("foo\x00bar", 7, module_object, "string_array[%i]", 3);
+
+  set_sized_string("foo\0bar", 7, module_object, "string_array[%i]", 3);
 
   set_string("foo", module_object, "string_dict[%s]", "foo");
   set_string("bar", module_object, "string_dict[\"bar\"]");
diff --git a/libyara/object.c b/libyara/object.c
index 1742a3a..94e94e7 100644
--- a/libyara/object.c
+++ b/libyara/object.c
@@ -255,12 +255,14 @@ int yr_object_from_external_variable(
     {
       case EXTERNAL_VARIABLE_TYPE_INTEGER:
       case EXTERNAL_VARIABLE_TYPE_BOOLEAN:
-        yr_object_set_integer(external->integer, obj, NULL);
+        yr_object_set_integer(
+            external->integer, obj, NULL);
         break;
 
       case EXTERNAL_VARIABLE_TYPE_STRING:
       case EXTERNAL_VARIABLE_TYPE_MALLOC_STRING:
-        yr_object_set_string(external->string, strlen(external->string), obj, NULL);
+        yr_object_set_string(
+            external->string, strlen(external->string), obj, NULL);
         break;
     }
 
@@ -889,10 +891,18 @@ void yr_object_set_string(
   if (string_obj->value != NULL)
     yr_free(string_obj->value);
 
-  string_obj->value = (SIZED_STRING*) yr_malloc(len + sizeof(SIZED_STRING));
-  string_obj->value->length = len;
-  string_obj->value->flags = 0;
-  memcpy(string_obj->value->c_string, value, len);
+  if (value != NULL)
+  {
+    string_obj->value = (SIZED_STRING*) yr_malloc(len + sizeof(SIZED_STRING));
+    string_obj->value->length = len;
+    string_obj->value->flags = 0;
+
+    memcpy(string_obj->value->c_string, value, len);
+  }
+  else
+  {
+    string_obj->value = NULL;
+  }
 }
 
 
diff --git a/libyara/parser.c b/libyara/parser.c
index 6efd96c..7802a64 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -724,10 +724,10 @@ int yr_parser_reduce_string_identifier(
 
       while(!STRING_IS_NULL(string))
       {
-        if (instruction != OP_STR_FOUND)
+        if (instruction != OP_FOUND)
           string->g_flags &= ~STRING_GFLAGS_SINGLE_MATCH;
 
-        if (instruction == OP_STR_FOUND_AT)
+        if (instruction == OP_FOUND_AT)
         {
           // Avoid overwriting any previous fixed offset
 
@@ -770,10 +770,10 @@ int yr_parser_reduce_string_identifier(
           PTR_TO_UINT64(string),
           NULL);
 
-      if (instruction != OP_STR_FOUND)
+      if (instruction != OP_FOUND)
         string->g_flags &= ~STRING_GFLAGS_SINGLE_MATCH;
 
-      if (instruction == OP_STR_FOUND_AT)
+      if (instruction == OP_FOUND_AT)
       {
         // Avoid overwriting any previous fixed offset
 

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