Browse code

Fix YARA arena management, improve error reporting, clean up some code.

Steven Morgan authored on 2015/05/08 04:50:37
Showing 13 changed files
... ...
@@ -315,7 +315,7 @@ int cl_init(unsigned int initoptions)
315 315
 
316 316
 struct cl_engine *cl_engine_new(void)
317 317
 {
318
-	struct cl_engine *new;
318
+    struct cl_engine *new;
319 319
     cli_intel_t *intel;
320 320
 
321 321
     new = (struct cl_engine *) cli_calloc(1, sizeof(struct cl_engine));
... ...
@@ -436,6 +436,44 @@ struct cl_engine *cl_engine_new(void)
436 436
     new->pcre_recmatch_limit = CLI_DEFAULT_PCRE_RECMATCH_LIMIT;
437 437
     new->pcre_max_filesize = CLI_DEFAULT_PCRE_MAX_FILESIZE;
438 438
 
439
+    /* Initialize YARA */
440
+    if (ERROR_SUCCESS != yr_arena_create(1024, 0, &new->the_arena)) {
441
+        cli_errmsg("cli_engine_new: failed to create the YARA arena\n");
442
+        mpool_free(new->mempool, new->dconf);
443
+        mpool_free(new->mempool, new->root);
444
+#ifdef USE_MPOOL
445
+        mpool_destroy(new->mempool);
446
+#endif
447
+        free(new);
448
+        free(intel);
449
+        return NULL;
450
+    }    
451
+    if (ERROR_SUCCESS != yr_hash_table_create(10007, &new->rules_table)) {
452
+        cli_errmsg("cli_engine_new: failed to create the YARA rules table\n");
453
+        yr_arena_destroy(new->the_arena);
454
+        mpool_free(new->mempool, new->dconf);
455
+        mpool_free(new->mempool, new->root);
456
+#ifdef USE_MPOOL
457
+        mpool_destroy(new->mempool);
458
+#endif
459
+        free(new);
460
+        free(intel);
461
+        return NULL;
462
+    }
463
+    if (ERROR_SUCCESS != yr_hash_table_create(10007, &new->objects_table)) {
464
+        cli_errmsg("cli_engine_new: failed to create the YARA objects table\n");
465
+        yr_hash_table_destroy(new->rules_table, NULL);
466
+        yr_arena_destroy(new->the_arena);
467
+        mpool_free(new->mempool, new->dconf);
468
+        mpool_free(new->mempool, new->root);
469
+#ifdef USE_MPOOL
470
+        mpool_destroy(new->mempool);
471
+#endif
472
+        free(new);
473
+        free(intel);
474
+        return NULL;
475
+    }
476
+
439 477
     cli_dbgmsg("Initialized %s engine\n", cl_retver());
440 478
     return new;
441 479
 }
... ...
@@ -53,6 +53,7 @@
53 53
 #ifdef HAVE_JSON
54 54
 #include "json.h"
55 55
 #endif
56
+#include "yara_clam.h"
56 57
 
57 58
 #if HAVE_LIBXML2
58 59
 #define CLAMAV_MIN_XMLREADER_FLAGS (XML_PARSE_NOERROR | XML_PARSE_NONET)
... ...
@@ -356,6 +357,11 @@ struct cl_engine {
356 356
     uint64_t pcre_match_limit;
357 357
     uint64_t pcre_recmatch_limit;
358 358
     uint64_t pcre_max_filesize;
359
+
360
+    /* YARA */
361
+    YR_ARENA      * the_arena;
362
+    YR_HASH_TABLE * rules_table;
363
+    YR_HASH_TABLE * objects_table;
359 364
 };
360 365
 
361 366
 struct cl_settings {
... ...
@@ -3774,11 +3774,7 @@ static int cli_loadyara(FILE *fs, struct cl_engine *engine, unsigned int *signo,
3774 3774
     STAILQ_INIT(&compiler.rule_q);
3775 3775
     STAILQ_INIT(&compiler.current_rule_string_q);
3776 3776
 
3777
-    rc = yr_hash_table_create(10007, &compiler.rules_table);
3778
-    if (rc == ERROR_SUCCESS)
3779
-        rc = yr_hash_table_create(10007, &compiler.objects_table);
3780
-    if (rc == ERROR_SUCCESS)
3781
-        rc = yr_arena_create(65536, 0, &compiler.sz_arena);
3777
+    rc = yr_arena_create(65536, 0, &compiler.sz_arena);
3782 3778
     if (rc == ERROR_SUCCESS)
3783 3779
         rc = yr_arena_create(65536, 0, &compiler.rules_arena);
3784 3780
     if (rc == ERROR_SUCCESS)
... ...
@@ -3792,17 +3788,18 @@ static int cli_loadyara(FILE *fs, struct cl_engine *engine, unsigned int *signo,
3792 3792
     compiler.loop_for_of_mem_offset = -1;
3793 3793
     ns.name = "default";
3794 3794
     compiler.current_namespace = &ns;
3795
+    compiler.the_arena = engine->the_arena;
3796
+    compiler.rules_table = engine->rules_table;
3797
+    compiler.objects_table = engine->objects_table;
3795 3798
 
3796 3799
     rc = yr_lex_parse_rules_file(fs, &compiler);
3797 3800
     if (rc > 0) { /* rc = number of errors */
3798 3801
         /* TODO - handle the various errors? */
3799 3802
         cli_errmsg("cli_loadyara: failed to parse rules file %s, error count %i\n", dbname, rc);
3800
-        yr_hash_table_destroy(compiler.rules_table, NULL);
3801
-        yr_hash_table_destroy(compiler.objects_table, NULL);
3802
-        //        yr_arena_destroy(compiler.sz_arena);
3803
-        //        yr_arena_destroy(compiler.rules_arena);
3803
+        yr_arena_destroy(compiler.sz_arena);
3804
+        yr_arena_destroy(compiler.rules_arena);
3804 3805
         yr_arena_destroy(compiler.code_arena);
3805
-        //        yr_arena_destroy(compiler.strings_arena);
3806
+        yr_arena_destroy(compiler.strings_arena);
3806 3807
         yr_arena_destroy(compiler.metas_arena);
3807 3808
 #ifdef YARA_FINISHED
3808 3809
         return CL_EMALFDB;
... ...
@@ -3826,12 +3823,10 @@ static int cli_loadyara(FILE *fs, struct cl_engine *engine, unsigned int *signo,
3826 3826
         }
3827 3827
     }
3828 3828
 
3829
-    yr_hash_table_destroy(compiler.rules_table, NULL);
3830
-    yr_hash_table_destroy(compiler.objects_table, NULL);
3831
-    //    yr_arena_destroy(compiler.sz_arena);
3832
-    //    yr_arena_destroy(compiler.rules_arena);
3829
+    yr_arena_append(engine->the_arena, compiler.sz_arena);
3830
+    yr_arena_append(engine->the_arena, compiler.rules_arena);
3831
+    yr_arena_append(engine->the_arena, compiler.strings_arena);
3833 3832
     yr_arena_destroy(compiler.code_arena);
3834
-    //    yr_arena_destroy(compiler.strings_arena);
3835 3833
     yr_arena_destroy(compiler.metas_arena);
3836 3834
 
3837 3835
     if(rc)
... ...
@@ -4285,6 +4280,7 @@ int cl_load(const char *path, struct cl_engine *engine, unsigned int *signo, uns
4285 4285
 	    cli_errmsg("cl_load(%s): Not supported database file type\n", path);
4286 4286
 	    return CL_EOPEN;
4287 4287
     }
4288
+
4288 4289
 #ifdef YARA_PROTO
4289 4290
     if (yara_total) {
4290 4291
         cli_yaramsg("$$$$$$$$$$$$ YARA $$$$$$$$$$$$\n");
... ...
@@ -4553,9 +4549,6 @@ int cl_engine_free(struct cl_engine *engine)
4553 4553
 		    for(j = 0; j < root->ac_lsigs; j++) {
4554 4554
 			if (root->ac_lsigtable[j]->type == CLI_LSIG_NORMAL)
4555 4555
 			    mpool_free(engine->mempool, root->ac_lsigtable[j]->u.logic);
4556
-			else if (root->ac_lsigtable[j]->type == CLI_YARA_NORMAL ||
4557
-                                 root->ac_lsigtable[j]->type == CLI_YARA_NORMAL)
4558
-			    free(root->ac_lsigtable[j]->u.code_start);
4559 4556
 			FREE_TDB(root->ac_lsigtable[j]->tdb);
4560 4557
 			mpool_free(engine->mempool, root->ac_lsigtable[j]);
4561 4558
 		    }
... ...
@@ -4667,6 +4660,16 @@ int cl_engine_free(struct cl_engine *engine)
4667 4667
 #ifdef USE_MPOOL
4668 4668
     if(engine->mempool) mpool_destroy(engine->mempool);
4669 4669
 #endif
4670
+
4671
+    if (engine->rules_table)
4672
+        yr_hash_table_destroy(engine->rules_table, NULL);
4673
+
4674
+    if (engine->objects_table)
4675
+        yr_hash_table_destroy(engine->objects_table, NULL);
4676
+
4677
+    if (engine->the_arena)
4678
+        yr_arena_destroy(engine->the_arena);
4679
+
4670 4680
     free(engine);
4671 4681
     return CL_SUCCESS;
4672 4682
 }
... ...
@@ -4680,6 +4683,13 @@ int cl_engine_compile(struct cl_engine *engine)
4680 4680
     if(!engine)
4681 4681
 	return CL_ENULLARG;
4682 4682
 
4683
+    /* Free YARA hash tables - only needed for parse and load */
4684
+    if (engine->rules_table)
4685
+        yr_hash_table_destroy(engine->rules_table, NULL);
4686
+    if (engine->objects_table)
4687
+        yr_hash_table_destroy(engine->objects_table, NULL);
4688
+    engine->rules_table = engine->objects_table = NULL;
4689
+
4683 4690
     if(!engine->ftypes)
4684 4691
 	if((ret = cli_loadftm(NULL, engine, 0, 1, NULL)))
4685 4692
 	    return ret;
... ...
@@ -31,8 +31,8 @@ from files.
31 31
 #include <time.h>
32 32
 #include <stdint.h>
33 33
 
34
-#include "yara_clam.h"
35 34
 #include <yara_arena.h>
35
+#include "yara_clam.h"
36 36
 #if REAL_YARA
37 37
 #include <yara/mem.h>
38 38
 #include <yara/error.h>
... ...
@@ -750,7 +750,7 @@ int yr_arena_write_string(
750 750
       (void**) written_string);
751 751
 }
752 752
 
753
-#if REAL_YARA
753
+
754 754
 //
755 755
 // yr_arena_append
756 756
 //
... ...
@@ -777,7 +777,7 @@ int yr_arena_append(
777 777
 
778 778
   return ERROR_SUCCESS;
779 779
 }
780
-#endif
780
+
781 781
 
782 782
 #if REAL_YARA
783 783
 //
... ...
@@ -41,9 +41,9 @@ limitations under the License.
41 41
 #define _YARA_CLAM_H_
42 42
 
43 43
 #include "shared/queue.h"
44
-#include "others.h"
45 44
 #include "yara_arena.h"
46 45
 #include "yara_hash.h"
46
+#include "others.h"
47 47
 
48 48
 /* From libyara/include/yara/types.h            */
49 49
 #define DECLARE_REFERENCE(type, name) \
... ...
@@ -313,95 +313,6 @@ typedef struct _SIZED_STRING
313 313
 #define RE_FLAGS_DOT_ALL                  0x80
314 314
 #define RE_FLAGS_NOT_AT_START            0x100
315 315
 
316
-/* From libyara/include/yara/exec.h            */
317
-
318
-#define UNDEFINED           0xFFFABADAFABADAFFLL
319
-#define IS_UNDEFINED(x)     ((x) == UNDEFINED)
320
-
321
-#define OP_HALT           255
322
-
323
-#define OP_AND            1
324
-#define OP_OR             2
325
-#define OP_XOR            3
326
-#define OP_NOT            4
327
-#define OP_LT             5
328
-#define OP_GT             6
329
-#define OP_LE             7
330
-#define OP_GE             8
331
-#define OP_EQ             9
332
-#define OP_NEQ            10
333
-#define OP_SZ_EQ          11
334
-#define OP_SZ_NEQ         12
335
-#define OP_SZ_TO_BOOL     13
336
-#define OP_ADD            14
337
-#define OP_SUB            15
338
-#define OP_MUL            16
339
-#define OP_DIV            17
340
-#define OP_MOD            18
341
-#define OP_NEG            19
342
-#define OP_SHL            20
343
-#define OP_SHR            21
344
-#define OP_PUSH           22
345
-#define OP_POP            23
346
-#define OP_CALL           24
347
-#define OP_OBJ_LOAD       25
348
-#define OP_OBJ_VALUE      26
349
-#define OP_OBJ_FIELD      27
350
-#define OP_INDEX_ARRAY    28
351
-#define OP_STR_COUNT      29
352
-#define OP_STR_FOUND      30
353
-#define OP_STR_FOUND_AT   31
354
-#define OP_STR_FOUND_IN   32
355
-#define OP_STR_OFFSET     33
356
-#define OP_OF             34
357
-#define OP_PUSH_RULE      35
358
-#define OP_MATCH_RULE     36
359
-#define OP_INCR_M         37
360
-#define OP_CLEAR_M        38
361
-#define OP_ADD_M          39
362
-#define OP_POP_M          40
363
-#define OP_PUSH_M         41
364
-#define OP_SWAPUNDEF      42
365
-#define OP_JNUNDEF        43
366
-#define OP_JLE            44
367
-#define OP_FILESIZE       45
368
-#define OP_ENTRYPOINT     46
369
-#define OP_INT8           47
370
-#define OP_INT16          48
371
-#define OP_INT32          49
372
-#define OP_UINT8          50
373
-#define OP_UINT16         51
374
-#define OP_UINT32         52
375
-#define OP_CONTAINS       53
376
-#define OP_MATCHES        54
377
-#define OP_IMPORT         55
378
-
379
-/*
380
-typedef struct _YR_MATCH
381
-{
382
-  int64_t offset;
383
-  int32_t length;
384
-
385
-  union {
386
-    uint8_t* data;            // Confirmed matches use "data",
387
-    int32_t chain_length;    // unconfirmed ones use "chain_length"
388
-  };
389
-
390
-  struct _YR_MATCH*  prev;
391
-  struct _YR_MATCH*  next;
392
-
393
-} YR_MATCH;
394
-
395
-typedef struct _YR_MATCHES
396
-{
397
-  int32_t count;
398
-
399
-  DECLARE_REFERENCE(YR_MATCH*, head);
400
-  DECLARE_REFERENCE(YR_MATCH*, tail);
401
-
402
-} YR_MATCHES;
403
-*/
404
-
405 316
 typedef struct _YR_META
406 317
 {
407 318
   int32_t type;
... ...
@@ -564,30 +475,31 @@ typedef struct _yc_compiler {
564 564
     int                 last_error_line;
565 565
     int                 last_result;
566 566
 
567
-    YR_ARENA*           sz_arena;
568
-    YR_ARENA*           rules_arena;
569
-    YR_ARENA*           strings_arena;
570
-    YR_ARENA*           code_arena;
571
-    YR_ARENA*           metas_arena;
572
-    YR_HASH_TABLE*      rules_table;
573
-    YR_HASH_TABLE*      objects_table;
574
-    YR_NAMESPACE*       current_namespace;
575
-    yc_string*          current_rule_strings;
567
+    YR_ARENA            *sz_arena;
568
+    YR_ARENA            *rules_arena;
569
+    YR_ARENA            *strings_arena;
570
+    YR_ARENA            *code_arena;
571
+    YR_ARENA            *metas_arena;
572
+    YR_ARENA            *the_arena;
573
+    YR_HASH_TABLE       *rules_table;
574
+    YR_HASH_TABLE       *objects_table;
575
+    YR_NAMESPACE        *current_namespace;
576
+    yc_string           *current_rule_strings;
576 577
     uint32_t            current_rule_flags;
577 578
     uint32_t            current_rule_clflags;
578 579
 
579
-    int8_t*             loop_address[MAX_LOOP_NESTING];
580
-    char*               loop_identifier[MAX_LOOP_NESTING];
580
+    int8_t              *loop_address[MAX_LOOP_NESTING];
581
+    char                *loop_identifier[MAX_LOOP_NESTING];
581 582
     int                 loop_depth;
582 583
     int                 loop_for_of_mem_offset;
583 584
 
584 585
     char                last_error_extra_info[MAX_COMPILER_ERROR_EXTRA_INFO];
585 586
 
586 587
     char                lex_buf[LEX_BUF_SIZE];
587
-    char*               lex_buf_ptr;
588
+    char                *lex_buf_ptr;
588 589
     unsigned short      lex_buf_len;
589 590
 
590
-    char *              error_msg;   
591
+    char                *error_msg;   
591 592
 
592 593
     STAILQ_HEAD(rq, _yc_rule) rule_q;
593 594
     STAILQ_HEAD(cs, _yc_string) current_rule_string_q;
... ...
@@ -165,7 +165,7 @@ int yr_execute_code(
165 165
 
166 166
   while(1)
167 167
   {
168
-      //    cli_errmsg("yara_exec: executing %i\n", *ip);
168
+    cli_dbgmsg("yara_exec: executing %i\n", *ip);
169 169
     switch(*ip)
170 170
     {
171 171
       case OP_HALT:
... ...
@@ -101,6 +101,7 @@
101 101
 #include "libclamav/yara_grammar.h"
102 102
 #include "libclamav/yara_lexer.h"
103 103
 #include "libclamav/yara_parser.h"
104
+#include "libclamav/yara_exec.h"
104 105
 #endif
105 106
 
106 107
 #define YYERROR_VERBOSE
... ...
@@ -150,7 +151,7 @@
150 150
 
151 151
 
152 152
 /* Line 268 of yacc.c  */
153
-#line 154 "yara_grammar.c"
153
+#line 155 "yara_grammar.c"
154 154
 
155 155
 /* Enabling traces.  */
156 156
 #ifndef YYDEBUG
... ...
@@ -291,7 +292,7 @@ typedef union YYSTYPE
291 291
 {
292 292
 
293 293
 /* Line 293 of yacc.c  */
294
-#line 213 "yara_grammar.y"
294
+#line 214 "yara_grammar.y"
295 295
 
296 296
   SIZED_STRING*   sized_string;
297 297
   char*           c_string;
... ...
@@ -304,7 +305,7 @@ typedef union YYSTYPE
304 304
 
305 305
 
306 306
 /* Line 293 of yacc.c  */
307
-#line 308 "yara_grammar.c"
307
+#line 309 "yara_grammar.c"
308 308
 } YYSTYPE;
309 309
 # define YYSTYPE_IS_TRIVIAL 1
310 310
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
... ...
@@ -316,7 +317,7 @@ typedef union YYSTYPE
316 316
 
317 317
 
318 318
 /* Line 343 of yacc.c  */
319
-#line 320 "yara_grammar.c"
319
+#line 321 "yara_grammar.c"
320 320
 
321 321
 #ifdef short
322 322
 # undef short
... ...
@@ -654,18 +655,18 @@ static const yytype_int8 yyrhs[] =
654 654
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
655 655
 static const yytype_uint16 yyrline[] =
656 656
 {
657
-       0,   226,   226,   228,   229,   230,   231,   236,   248,   267,
658
-     270,   300,   304,   332,   337,   338,   343,   344,   350,   353,
659
-     373,   390,   429,   430,   435,   451,   464,   477,   494,   495,
660
-     500,   514,   513,   530,   547,   548,   553,   554,   555,   556,
661
-     561,   646,   696,   719,   759,   762,   784,   817,   864,   882,
662
-     891,   900,   915,   929,   942,   959,   975,  1009,   974,  1120,
663
-    1119,  1195,  1201,  1207,  1213,  1221,  1230,  1239,  1248,  1257,
664
-    1284,  1311,  1338,  1342,  1350,  1351,  1356,  1378,  1390,  1406,
665
-    1405,  1411,  1423,  1424,  1429,  1434,  1443,  1444,  1451,  1462,
666
-    1466,  1475,  1490,  1501,  1512,  1523,  1534,  1545,  1556,  1565,
667
-    1590,  1603,  1618,  1640,  1675,  1684,  1693,  1702,  1711,  1720,
668
-    1729,  1738,  1747,  1755,  1764,  1773
657
+       0,   227,   227,   229,   230,   231,   232,   237,   249,   268,
658
+     271,   301,   305,   333,   338,   339,   344,   345,   351,   354,
659
+     374,   391,   430,   431,   436,   452,   465,   478,   495,   496,
660
+     501,   515,   514,   531,   548,   549,   554,   555,   556,   557,
661
+     562,   647,   697,   720,   760,   763,   785,   818,   865,   883,
662
+     892,   901,   916,   930,   943,   960,   976,  1010,   975,  1121,
663
+    1120,  1196,  1202,  1208,  1214,  1222,  1231,  1240,  1249,  1258,
664
+    1285,  1312,  1339,  1343,  1351,  1352,  1357,  1379,  1391,  1407,
665
+    1406,  1412,  1424,  1425,  1430,  1435,  1444,  1445,  1452,  1463,
666
+    1467,  1476,  1491,  1502,  1513,  1524,  1535,  1546,  1557,  1566,
667
+    1591,  1604,  1619,  1641,  1676,  1685,  1694,  1703,  1712,  1721,
668
+    1730,  1739,  1748,  1756,  1765,  1774
669 669
 };
670 670
 #endif
671 671
 
... ...
@@ -1505,74 +1506,74 @@ yydestruct (yymsg, yytype, yyvaluep, yyscanner, compiler)
1505 1505
       case 9: /* "_IDENTIFIER_" */
1506 1506
 
1507 1507
 /* Line 1391 of yacc.c  */
1508
-#line 204 "yara_grammar.y"
1508
+#line 205 "yara_grammar.y"
1509 1509
 	{ yr_free((yyvaluep->c_string)); };
1510 1510
 
1511 1511
 /* Line 1391 of yacc.c  */
1512
-#line 1513 "yara_grammar.c"
1512
+#line 1514 "yara_grammar.c"
1513 1513
 	break;
1514 1514
       case 10: /* "_STRING_IDENTIFIER_" */
1515 1515
 
1516 1516
 /* Line 1391 of yacc.c  */
1517
-#line 205 "yara_grammar.y"
1517
+#line 206 "yara_grammar.y"
1518 1518
 	{ yr_free((yyvaluep->c_string)); };
1519 1519
 
1520 1520
 /* Line 1391 of yacc.c  */
1521
-#line 1522 "yara_grammar.c"
1521
+#line 1523 "yara_grammar.c"
1522 1522
 	break;
1523 1523
       case 11: /* "_STRING_COUNT_" */
1524 1524
 
1525 1525
 /* Line 1391 of yacc.c  */
1526
-#line 206 "yara_grammar.y"
1526
+#line 207 "yara_grammar.y"
1527 1527
 	{ yr_free((yyvaluep->c_string)); };
1528 1528
 
1529 1529
 /* Line 1391 of yacc.c  */
1530
-#line 1531 "yara_grammar.c"
1530
+#line 1532 "yara_grammar.c"
1531 1531
 	break;
1532 1532
       case 12: /* "_STRING_OFFSET_" */
1533 1533
 
1534 1534
 /* Line 1391 of yacc.c  */
1535
-#line 207 "yara_grammar.y"
1535
+#line 208 "yara_grammar.y"
1536 1536
 	{ yr_free((yyvaluep->c_string)); };
1537 1537
 
1538 1538
 /* Line 1391 of yacc.c  */
1539
-#line 1540 "yara_grammar.c"
1539
+#line 1541 "yara_grammar.c"
1540 1540
 	break;
1541 1541
       case 13: /* "_STRING_IDENTIFIER_WITH_WILDCARD_" */
1542 1542
 
1543 1543
 /* Line 1391 of yacc.c  */
1544
-#line 208 "yara_grammar.y"
1544
+#line 209 "yara_grammar.y"
1545 1545
 	{ yr_free((yyvaluep->c_string)); };
1546 1546
 
1547 1547
 /* Line 1391 of yacc.c  */
1548
-#line 1549 "yara_grammar.c"
1548
+#line 1550 "yara_grammar.c"
1549 1549
 	break;
1550 1550
       case 15: /* "_TEXT_STRING_" */
1551 1551
 
1552 1552
 /* Line 1391 of yacc.c  */
1553
-#line 209 "yara_grammar.y"
1553
+#line 210 "yara_grammar.y"
1554 1554
 	{ yr_free((yyvaluep->sized_string)); };
1555 1555
 
1556 1556
 /* Line 1391 of yacc.c  */
1557
-#line 1558 "yara_grammar.c"
1557
+#line 1559 "yara_grammar.c"
1558 1558
 	break;
1559 1559
       case 16: /* "_HEX_STRING_" */
1560 1560
 
1561 1561
 /* Line 1391 of yacc.c  */
1562
-#line 210 "yara_grammar.y"
1562
+#line 211 "yara_grammar.y"
1563 1563
 	{ yr_free((yyvaluep->sized_string)); };
1564 1564
 
1565 1565
 /* Line 1391 of yacc.c  */
1566
-#line 1567 "yara_grammar.c"
1566
+#line 1568 "yara_grammar.c"
1567 1567
 	break;
1568 1568
       case 17: /* "_REGEXP_" */
1569 1569
 
1570 1570
 /* Line 1391 of yacc.c  */
1571
-#line 211 "yara_grammar.y"
1571
+#line 212 "yara_grammar.y"
1572 1572
 	{ yr_free((yyvaluep->sized_string)); };
1573 1573
 
1574 1574
 /* Line 1391 of yacc.c  */
1575
-#line 1576 "yara_grammar.c"
1575
+#line 1577 "yara_grammar.c"
1576 1576
 	break;
1577 1577
 
1578 1578
       default:
... ...
@@ -1875,7 +1876,7 @@ yyreduce:
1875 1875
         case 7:
1876 1876
 
1877 1877
 /* Line 1806 of yacc.c  */
1878
-#line 237 "yara_grammar.y"
1878
+#line 238 "yara_grammar.y"
1879 1879
     {
1880 1880
         int result = yr_parser_reduce_import(yyscanner, (yyvsp[(2) - (2)].sized_string));
1881 1881
 
... ...
@@ -1888,7 +1889,7 @@ yyreduce:
1888 1888
   case 8:
1889 1889
 
1890 1890
 /* Line 1806 of yacc.c  */
1891
-#line 249 "yara_grammar.y"
1891
+#line 250 "yara_grammar.y"
1892 1892
     {
1893 1893
         int result = yr_parser_reduce_rule_declaration(
1894 1894
             yyscanner,
... ...
@@ -1907,7 +1908,7 @@ yyreduce:
1907 1907
   case 9:
1908 1908
 
1909 1909
 /* Line 1806 of yacc.c  */
1910
-#line 267 "yara_grammar.y"
1910
+#line 268 "yara_grammar.y"
1911 1911
     {
1912 1912
         (yyval.meta) = NULL;
1913 1913
       }
... ...
@@ -1916,7 +1917,7 @@ yyreduce:
1916 1916
   case 10:
1917 1917
 
1918 1918
 /* Line 1806 of yacc.c  */
1919
-#line 271 "yara_grammar.y"
1919
+#line 272 "yara_grammar.y"
1920 1920
     {
1921 1921
 #if REAL_YARA //Meta not supported
1922 1922
         // Each rule have a list of meta-data info, consisting in a
... ...
@@ -1946,7 +1947,7 @@ yyreduce:
1946 1946
   case 11:
1947 1947
 
1948 1948
 /* Line 1806 of yacc.c  */
1949
-#line 300 "yara_grammar.y"
1949
+#line 301 "yara_grammar.y"
1950 1950
     {
1951 1951
         (yyval.string) = NULL;
1952 1952
         compiler->current_rule_strings = (yyval.string);
... ...
@@ -1956,7 +1957,7 @@ yyreduce:
1956 1956
   case 12:
1957 1957
 
1958 1958
 /* Line 1806 of yacc.c  */
1959
-#line 305 "yara_grammar.y"
1959
+#line 306 "yara_grammar.y"
1960 1960
     {
1961 1961
         // Each rule have a list of strings, consisting in a sequence
1962 1962
         // of YR_STRING structures. The last YR_STRING structure does not
... ...
@@ -1985,35 +1986,35 @@ yyreduce:
1985 1985
   case 14:
1986 1986
 
1987 1987
 /* Line 1806 of yacc.c  */
1988
-#line 337 "yara_grammar.y"
1988
+#line 338 "yara_grammar.y"
1989 1989
     { (yyval.integer) = 0;  }
1990 1990
     break;
1991 1991
 
1992 1992
   case 15:
1993 1993
 
1994 1994
 /* Line 1806 of yacc.c  */
1995
-#line 338 "yara_grammar.y"
1995
+#line 339 "yara_grammar.y"
1996 1996
     { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
1997 1997
     break;
1998 1998
 
1999 1999
   case 16:
2000 2000
 
2001 2001
 /* Line 1806 of yacc.c  */
2002
-#line 343 "yara_grammar.y"
2002
+#line 344 "yara_grammar.y"
2003 2003
     { (yyval.integer) = RULE_GFLAGS_PRIVATE; }
2004 2004
     break;
2005 2005
 
2006 2006
   case 17:
2007 2007
 
2008 2008
 /* Line 1806 of yacc.c  */
2009
-#line 344 "yara_grammar.y"
2009
+#line 345 "yara_grammar.y"
2010 2010
     { (yyval.integer) = RULE_GFLAGS_GLOBAL; }
2011 2011
     break;
2012 2012
 
2013 2013
   case 18:
2014 2014
 
2015 2015
 /* Line 1806 of yacc.c  */
2016
-#line 350 "yara_grammar.y"
2016
+#line 351 "yara_grammar.y"
2017 2017
     {
2018 2018
         (yyval.c_string) = NULL;
2019 2019
       }
... ...
@@ -2022,7 +2023,7 @@ yyreduce:
2022 2022
   case 19:
2023 2023
 
2024 2024
 /* Line 1806 of yacc.c  */
2025
-#line 354 "yara_grammar.y"
2025
+#line 355 "yara_grammar.y"
2026 2026
     {
2027 2027
 #if REAL_YARA //tags not supported
2028 2028
         // Tags list is represented in the arena as a sequence
... ...
@@ -2043,7 +2044,7 @@ yyreduce:
2043 2043
   case 20:
2044 2044
 
2045 2045
 /* Line 1806 of yacc.c  */
2046
-#line 374 "yara_grammar.y"
2046
+#line 375 "yara_grammar.y"
2047 2047
     {
2048 2048
 #if REAL_YARA //tags not supported
2049 2049
         char* identifier;
... ...
@@ -2065,7 +2066,7 @@ yyreduce:
2065 2065
   case 21:
2066 2066
 
2067 2067
 /* Line 1806 of yacc.c  */
2068
-#line 391 "yara_grammar.y"
2068
+#line 392 "yara_grammar.y"
2069 2069
     {
2070 2070
 #if REAL_YARA //tags not supported
2071 2071
         char* tag_name = (yyvsp[(1) - (2)].c_string);
... ...
@@ -2104,21 +2105,21 @@ yyreduce:
2104 2104
   case 22:
2105 2105
 
2106 2106
 /* Line 1806 of yacc.c  */
2107
-#line 429 "yara_grammar.y"
2107
+#line 430 "yara_grammar.y"
2108 2108
     {  (yyval.meta) = (yyvsp[(1) - (1)].meta); }
2109 2109
     break;
2110 2110
 
2111 2111
   case 23:
2112 2112
 
2113 2113
 /* Line 1806 of yacc.c  */
2114
-#line 430 "yara_grammar.y"
2114
+#line 431 "yara_grammar.y"
2115 2115
     {  (yyval.meta) = (yyvsp[(1) - (2)].meta); }
2116 2116
     break;
2117 2117
 
2118 2118
   case 24:
2119 2119
 
2120 2120
 /* Line 1806 of yacc.c  */
2121
-#line 436 "yara_grammar.y"
2121
+#line 437 "yara_grammar.y"
2122 2122
     {
2123 2123
         SIZED_STRING* sized_string = (yyvsp[(3) - (3)].sized_string);
2124 2124
 
... ...
@@ -2139,7 +2140,7 @@ yyreduce:
2139 2139
   case 25:
2140 2140
 
2141 2141
 /* Line 1806 of yacc.c  */
2142
-#line 452 "yara_grammar.y"
2142
+#line 453 "yara_grammar.y"
2143 2143
     {
2144 2144
         (yyval.meta) = yr_parser_reduce_meta_declaration(
2145 2145
             yyscanner,
... ...
@@ -2157,7 +2158,7 @@ yyreduce:
2157 2157
   case 26:
2158 2158
 
2159 2159
 /* Line 1806 of yacc.c  */
2160
-#line 465 "yara_grammar.y"
2160
+#line 466 "yara_grammar.y"
2161 2161
     {
2162 2162
         (yyval.meta) = yr_parser_reduce_meta_declaration(
2163 2163
             yyscanner,
... ...
@@ -2175,7 +2176,7 @@ yyreduce:
2175 2175
   case 27:
2176 2176
 
2177 2177
 /* Line 1806 of yacc.c  */
2178
-#line 478 "yara_grammar.y"
2178
+#line 479 "yara_grammar.y"
2179 2179
     {
2180 2180
         (yyval.meta) = yr_parser_reduce_meta_declaration(
2181 2181
             yyscanner,
... ...
@@ -2193,21 +2194,21 @@ yyreduce:
2193 2193
   case 28:
2194 2194
 
2195 2195
 /* Line 1806 of yacc.c  */
2196
-#line 494 "yara_grammar.y"
2196
+#line 495 "yara_grammar.y"
2197 2197
     { (yyval.string) = (yyvsp[(1) - (1)].string); }
2198 2198
     break;
2199 2199
 
2200 2200
   case 29:
2201 2201
 
2202 2202
 /* Line 1806 of yacc.c  */
2203
-#line 495 "yara_grammar.y"
2203
+#line 496 "yara_grammar.y"
2204 2204
     { (yyval.string) = (yyvsp[(1) - (2)].string); }
2205 2205
     break;
2206 2206
 
2207 2207
   case 30:
2208 2208
 
2209 2209
 /* Line 1806 of yacc.c  */
2210
-#line 501 "yara_grammar.y"
2210
+#line 502 "yara_grammar.y"
2211 2211
     {
2212 2212
         (yyval.string) = yr_parser_reduce_string_declaration(
2213 2213
             yyscanner,
... ...
@@ -2225,7 +2226,7 @@ yyreduce:
2225 2225
   case 31:
2226 2226
 
2227 2227
 /* Line 1806 of yacc.c  */
2228
-#line 514 "yara_grammar.y"
2228
+#line 515 "yara_grammar.y"
2229 2229
     {
2230 2230
         compiler->error_line = yyget_lineno(yyscanner);
2231 2231
       }
... ...
@@ -2234,7 +2235,7 @@ yyreduce:
2234 2234
   case 32:
2235 2235
 
2236 2236
 /* Line 1806 of yacc.c  */
2237
-#line 518 "yara_grammar.y"
2237
+#line 519 "yara_grammar.y"
2238 2238
     {
2239 2239
         (yyval.string) = yr_parser_reduce_string_declaration(
2240 2240
             yyscanner,
... ...
@@ -2252,7 +2253,7 @@ yyreduce:
2252 2252
   case 33:
2253 2253
 
2254 2254
 /* Line 1806 of yacc.c  */
2255
-#line 531 "yara_grammar.y"
2255
+#line 532 "yara_grammar.y"
2256 2256
     {
2257 2257
         (yyval.string) = yr_parser_reduce_string_declaration(
2258 2258
             yyscanner,
... ...
@@ -2270,49 +2271,49 @@ yyreduce:
2270 2270
   case 34:
2271 2271
 
2272 2272
 /* Line 1806 of yacc.c  */
2273
-#line 547 "yara_grammar.y"
2273
+#line 548 "yara_grammar.y"
2274 2274
     { (yyval.integer) = 0; }
2275 2275
     break;
2276 2276
 
2277 2277
   case 35:
2278 2278
 
2279 2279
 /* Line 1806 of yacc.c  */
2280
-#line 548 "yara_grammar.y"
2280
+#line 549 "yara_grammar.y"
2281 2281
     { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
2282 2282
     break;
2283 2283
 
2284 2284
   case 36:
2285 2285
 
2286 2286
 /* Line 1806 of yacc.c  */
2287
-#line 553 "yara_grammar.y"
2287
+#line 554 "yara_grammar.y"
2288 2288
     { (yyval.integer) = STRING_GFLAGS_WIDE; }
2289 2289
     break;
2290 2290
 
2291 2291
   case 37:
2292 2292
 
2293 2293
 /* Line 1806 of yacc.c  */
2294
-#line 554 "yara_grammar.y"
2294
+#line 555 "yara_grammar.y"
2295 2295
     { (yyval.integer) = STRING_GFLAGS_ASCII; }
2296 2296
     break;
2297 2297
 
2298 2298
   case 38:
2299 2299
 
2300 2300
 /* Line 1806 of yacc.c  */
2301
-#line 555 "yara_grammar.y"
2301
+#line 556 "yara_grammar.y"
2302 2302
     { (yyval.integer) = STRING_GFLAGS_NO_CASE; }
2303 2303
     break;
2304 2304
 
2305 2305
   case 39:
2306 2306
 
2307 2307
 /* Line 1806 of yacc.c  */
2308
-#line 556 "yara_grammar.y"
2308
+#line 557 "yara_grammar.y"
2309 2309
     { (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
2310 2310
     break;
2311 2311
 
2312 2312
   case 40:
2313 2313
 
2314 2314
 /* Line 1806 of yacc.c  */
2315
-#line 562 "yara_grammar.y"
2315
+#line 563 "yara_grammar.y"
2316 2316
     {
2317 2317
         YR_OBJECT* object = NULL;
2318 2318
         YR_RULE* rule;
... ...
@@ -2402,7 +2403,7 @@ yyreduce:
2402 2402
   case 41:
2403 2403
 
2404 2404
 /* Line 1806 of yacc.c  */
2405
-#line 647 "yara_grammar.y"
2405
+#line 648 "yara_grammar.y"
2406 2406
     {
2407 2407
         YR_OBJECT* object = (yyvsp[(1) - (3)].object);
2408 2408
         YR_OBJECT* field = NULL;
... ...
@@ -2457,7 +2458,7 @@ yyreduce:
2457 2457
   case 42:
2458 2458
 
2459 2459
 /* Line 1806 of yacc.c  */
2460
-#line 697 "yara_grammar.y"
2460
+#line 698 "yara_grammar.y"
2461 2461
     {
2462 2462
         if ((yyvsp[(1) - (4)].object) != NULL && (yyvsp[(1) - (4)].object)->type == OBJECT_TYPE_ARRAY)
2463 2463
         {
... ...
@@ -2484,7 +2485,7 @@ yyreduce:
2484 2484
   case 43:
2485 2485
 
2486 2486
 /* Line 1806 of yacc.c  */
2487
-#line 720 "yara_grammar.y"
2487
+#line 721 "yara_grammar.y"
2488 2488
     {
2489 2489
         int args_count;
2490 2490
 
... ...
@@ -2524,7 +2525,7 @@ yyreduce:
2524 2524
   case 44:
2525 2525
 
2526 2526
 /* Line 1806 of yacc.c  */
2527
-#line 759 "yara_grammar.y"
2527
+#line 760 "yara_grammar.y"
2528 2528
     {
2529 2529
         (yyval.c_string) = yr_strdup("");
2530 2530
       }
... ...
@@ -2533,7 +2534,7 @@ yyreduce:
2533 2533
   case 45:
2534 2534
 
2535 2535
 /* Line 1806 of yacc.c  */
2536
-#line 763 "yara_grammar.y"
2536
+#line 764 "yara_grammar.y"
2537 2537
     {
2538 2538
         (yyval.c_string) = yr_malloc(MAX_FUNCTION_ARGS + 1);
2539 2539
 
... ...
@@ -2560,7 +2561,7 @@ yyreduce:
2560 2560
   case 46:
2561 2561
 
2562 2562
 /* Line 1806 of yacc.c  */
2563
-#line 785 "yara_grammar.y"
2563
+#line 786 "yara_grammar.y"
2564 2564
     {
2565 2565
         if (strlen((yyvsp[(1) - (3)].c_string)) == MAX_FUNCTION_ARGS)
2566 2566
         {
... ...
@@ -2594,7 +2595,7 @@ yyreduce:
2594 2594
   case 47:
2595 2595
 
2596 2596
 /* Line 1806 of yacc.c  */
2597
-#line 818 "yara_grammar.y"
2597
+#line 819 "yara_grammar.y"
2598 2598
     {
2599 2599
 #ifdef REAL_YARA
2600 2600
         SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
... ...
@@ -2642,7 +2643,7 @@ yyreduce:
2642 2642
   case 48:
2643 2643
 
2644 2644
 /* Line 1806 of yacc.c  */
2645
-#line 865 "yara_grammar.y"
2645
+#line 866 "yara_grammar.y"
2646 2646
     {
2647 2647
         if ((yyvsp[(1) - (1)].expression_type) == EXPRESSION_TYPE_STRING)
2648 2648
         {
... ...
@@ -2662,7 +2663,7 @@ yyreduce:
2662 2662
   case 49:
2663 2663
 
2664 2664
 /* Line 1806 of yacc.c  */
2665
-#line 883 "yara_grammar.y"
2665
+#line 884 "yara_grammar.y"
2666 2666
     {
2667 2667
         compiler->last_result = yr_parser_emit_with_arg(
2668 2668
             yyscanner, OP_PUSH, 1, NULL);
... ...
@@ -2676,7 +2677,7 @@ yyreduce:
2676 2676
   case 50:
2677 2677
 
2678 2678
 /* Line 1806 of yacc.c  */
2679
-#line 892 "yara_grammar.y"
2679
+#line 893 "yara_grammar.y"
2680 2680
     {
2681 2681
         compiler->last_result = yr_parser_emit_with_arg(
2682 2682
             yyscanner, OP_PUSH, 0, NULL);
... ...
@@ -2690,7 +2691,7 @@ yyreduce:
2690 2690
   case 51:
2691 2691
 
2692 2692
 /* Line 1806 of yacc.c  */
2693
-#line 901 "yara_grammar.y"
2693
+#line 902 "yara_grammar.y"
2694 2694
     {
2695 2695
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_STRING, "matches");
2696 2696
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_REGEXP, "matches");
... ...
@@ -2710,7 +2711,7 @@ yyreduce:
2710 2710
   case 52:
2711 2711
 
2712 2712
 /* Line 1806 of yacc.c  */
2713
-#line 916 "yara_grammar.y"
2713
+#line 917 "yara_grammar.y"
2714 2714
     {
2715 2715
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_STRING, "contains");
2716 2716
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_STRING, "contains");
... ...
@@ -2729,7 +2730,7 @@ yyreduce:
2729 2729
   case 53:
2730 2730
 
2731 2731
 /* Line 1806 of yacc.c  */
2732
-#line 930 "yara_grammar.y"
2732
+#line 931 "yara_grammar.y"
2733 2733
     {
2734 2734
         int result = yr_parser_reduce_string_identifier(
2735 2735
             yyscanner,
... ...
@@ -2747,7 +2748,7 @@ yyreduce:
2747 2747
   case 54:
2748 2748
 
2749 2749
 /* Line 1806 of yacc.c  */
2750
-#line 943 "yara_grammar.y"
2750
+#line 944 "yara_grammar.y"
2751 2751
     {
2752 2752
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "at");
2753 2753
 
... ...
@@ -2769,7 +2770,7 @@ yyreduce:
2769 2769
   case 55:
2770 2770
 
2771 2771
 /* Line 1806 of yacc.c  */
2772
-#line 960 "yara_grammar.y"
2772
+#line 961 "yara_grammar.y"
2773 2773
     {
2774 2774
         compiler->last_result = yr_parser_reduce_string_identifier(
2775 2775
             yyscanner,
... ...
@@ -2789,7 +2790,7 @@ yyreduce:
2789 2789
   case 56:
2790 2790
 
2791 2791
 /* Line 1806 of yacc.c  */
2792
-#line 975 "yara_grammar.y"
2792
+#line 976 "yara_grammar.y"
2793 2793
     {
2794 2794
         int var_index;
2795 2795
 
... ...
@@ -2828,7 +2829,7 @@ yyreduce:
2828 2828
   case 57:
2829 2829
 
2830 2830
 /* Line 1806 of yacc.c  */
2831
-#line 1009 "yara_grammar.y"
2831
+#line 1010 "yara_grammar.y"
2832 2832
     {
2833 2833
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2834 2834
 
... ...
@@ -2868,7 +2869,7 @@ yyreduce:
2868 2868
   case 58:
2869 2869
 
2870 2870
 /* Line 1806 of yacc.c  */
2871
-#line 1044 "yara_grammar.y"
2871
+#line 1045 "yara_grammar.y"
2872 2872
     {
2873 2873
         int mem_offset;
2874 2874
 
... ...
@@ -2949,7 +2950,7 @@ yyreduce:
2949 2949
   case 59:
2950 2950
 
2951 2951
 /* Line 1806 of yacc.c  */
2952
-#line 1120 "yara_grammar.y"
2952
+#line 1121 "yara_grammar.y"
2953 2953
     {
2954 2954
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2955 2955
         int8_t* addr;
... ...
@@ -2984,7 +2985,7 @@ yyreduce:
2984 2984
   case 60:
2985 2985
 
2986 2986
 /* Line 1806 of yacc.c  */
2987
-#line 1150 "yara_grammar.y"
2987
+#line 1151 "yara_grammar.y"
2988 2988
     {
2989 2989
         int mem_offset;
2990 2990
 
... ...
@@ -3035,7 +3036,7 @@ yyreduce:
3035 3035
   case 61:
3036 3036
 
3037 3037
 /* Line 1806 of yacc.c  */
3038
-#line 1196 "yara_grammar.y"
3038
+#line 1197 "yara_grammar.y"
3039 3039
     {
3040 3040
         yr_parser_emit(yyscanner, OP_OF, NULL);
3041 3041
 
... ...
@@ -3046,7 +3047,7 @@ yyreduce:
3046 3046
   case 62:
3047 3047
 
3048 3048
 /* Line 1806 of yacc.c  */
3049
-#line 1202 "yara_grammar.y"
3049
+#line 1203 "yara_grammar.y"
3050 3050
     {
3051 3051
         yr_parser_emit(yyscanner, OP_NOT, NULL);
3052 3052
 
... ...
@@ -3057,7 +3058,7 @@ yyreduce:
3057 3057
   case 63:
3058 3058
 
3059 3059
 /* Line 1806 of yacc.c  */
3060
-#line 1208 "yara_grammar.y"
3060
+#line 1209 "yara_grammar.y"
3061 3061
     {
3062 3062
         yr_parser_emit(yyscanner, OP_AND, NULL);
3063 3063
 
... ...
@@ -3068,7 +3069,7 @@ yyreduce:
3068 3068
   case 64:
3069 3069
 
3070 3070
 /* Line 1806 of yacc.c  */
3071
-#line 1214 "yara_grammar.y"
3071
+#line 1215 "yara_grammar.y"
3072 3072
     {
3073 3073
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_BOOLEAN, "or");
3074 3074
 
... ...
@@ -3081,7 +3082,7 @@ yyreduce:
3081 3081
   case 65:
3082 3082
 
3083 3083
 /* Line 1806 of yacc.c  */
3084
-#line 1222 "yara_grammar.y"
3084
+#line 1223 "yara_grammar.y"
3085 3085
     {
3086 3086
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<");
3087 3087
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<");
... ...
@@ -3095,7 +3096,7 @@ yyreduce:
3095 3095
   case 66:
3096 3096
 
3097 3097
 /* Line 1806 of yacc.c  */
3098
-#line 1231 "yara_grammar.y"
3098
+#line 1232 "yara_grammar.y"
3099 3099
     {
3100 3100
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">");
3101 3101
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">");
... ...
@@ -3109,7 +3110,7 @@ yyreduce:
3109 3109
   case 67:
3110 3110
 
3111 3111
 /* Line 1806 of yacc.c  */
3112
-#line 1240 "yara_grammar.y"
3112
+#line 1241 "yara_grammar.y"
3113 3113
     {
3114 3114
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<=");
3115 3115
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<=");
... ...
@@ -3123,7 +3124,7 @@ yyreduce:
3123 3123
   case 68:
3124 3124
 
3125 3125
 /* Line 1806 of yacc.c  */
3126
-#line 1249 "yara_grammar.y"
3126
+#line 1250 "yara_grammar.y"
3127 3127
     {
3128 3128
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">=");
3129 3129
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">=");
... ...
@@ -3137,7 +3138,7 @@ yyreduce:
3137 3137
   case 69:
3138 3138
 
3139 3139
 /* Line 1806 of yacc.c  */
3140
-#line 1258 "yara_grammar.y"
3140
+#line 1259 "yara_grammar.y"
3141 3141
     {
3142 3142
         if ((yyvsp[(1) - (3)].expression_type) != (yyvsp[(3) - (3)].expression_type))
3143 3143
         {
... ...
@@ -3169,7 +3170,7 @@ yyreduce:
3169 3169
   case 70:
3170 3170
 
3171 3171
 /* Line 1806 of yacc.c  */
3172
-#line 1285 "yara_grammar.y"
3172
+#line 1286 "yara_grammar.y"
3173 3173
     {
3174 3174
         if ((yyvsp[(1) - (3)].expression_type) != (yyvsp[(3) - (3)].expression_type))
3175 3175
         {
... ...
@@ -3201,7 +3202,7 @@ yyreduce:
3201 3201
   case 71:
3202 3202
 
3203 3203
 /* Line 1806 of yacc.c  */
3204
-#line 1312 "yara_grammar.y"
3204
+#line 1313 "yara_grammar.y"
3205 3205
     {
3206 3206
         if ((yyvsp[(1) - (3)].expression_type) != (yyvsp[(3) - (3)].expression_type))
3207 3207
         {
... ...
@@ -3233,7 +3234,7 @@ yyreduce:
3233 3233
   case 72:
3234 3234
 
3235 3235
 /* Line 1806 of yacc.c  */
3236
-#line 1339 "yara_grammar.y"
3236
+#line 1340 "yara_grammar.y"
3237 3237
     {
3238 3238
         (yyval.expression_type) = (yyvsp[(1) - (1)].expression_type);
3239 3239
       }
... ...
@@ -3242,7 +3243,7 @@ yyreduce:
3242 3242
   case 73:
3243 3243
 
3244 3244
 /* Line 1806 of yacc.c  */
3245
-#line 1343 "yara_grammar.y"
3245
+#line 1344 "yara_grammar.y"
3246 3246
     {
3247 3247
         (yyval.expression_type) = (yyvsp[(2) - (3)].expression_type);
3248 3248
       }
... ...
@@ -3251,21 +3252,21 @@ yyreduce:
3251 3251
   case 74:
3252 3252
 
3253 3253
 /* Line 1806 of yacc.c  */
3254
-#line 1350 "yara_grammar.y"
3254
+#line 1351 "yara_grammar.y"
3255 3255
     { (yyval.integer) = INTEGER_SET_ENUMERATION; }
3256 3256
     break;
3257 3257
 
3258 3258
   case 75:
3259 3259
 
3260 3260
 /* Line 1806 of yacc.c  */
3261
-#line 1351 "yara_grammar.y"
3261
+#line 1352 "yara_grammar.y"
3262 3262
     { (yyval.integer) = INTEGER_SET_RANGE; }
3263 3263
     break;
3264 3264
 
3265 3265
   case 76:
3266 3266
 
3267 3267
 /* Line 1806 of yacc.c  */
3268
-#line 1357 "yara_grammar.y"
3268
+#line 1358 "yara_grammar.y"
3269 3269
     {
3270 3270
         if ((yyvsp[(2) - (6)].expression_type) != EXPRESSION_TYPE_INTEGER)
3271 3271
         {
... ...
@@ -3288,7 +3289,7 @@ yyreduce:
3288 3288
   case 77:
3289 3289
 
3290 3290
 /* Line 1806 of yacc.c  */
3291
-#line 1379 "yara_grammar.y"
3291
+#line 1380 "yara_grammar.y"
3292 3292
     {
3293 3293
         if ((yyvsp[(1) - (1)].expression_type) != EXPRESSION_TYPE_INTEGER)
3294 3294
         {
... ...
@@ -3305,7 +3306,7 @@ yyreduce:
3305 3305
   case 78:
3306 3306
 
3307 3307
 /* Line 1806 of yacc.c  */
3308
-#line 1391 "yara_grammar.y"
3308
+#line 1392 "yara_grammar.y"
3309 3309
     {
3310 3310
         if ((yyvsp[(3) - (3)].expression_type) != EXPRESSION_TYPE_INTEGER)
3311 3311
         {
... ...
@@ -3321,7 +3322,7 @@ yyreduce:
3321 3321
   case 79:
3322 3322
 
3323 3323
 /* Line 1806 of yacc.c  */
3324
-#line 1406 "yara_grammar.y"
3324
+#line 1407 "yara_grammar.y"
3325 3325
     {
3326 3326
         // Push end-of-list marker
3327 3327
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
... ...
@@ -3331,7 +3332,7 @@ yyreduce:
3331 3331
   case 81:
3332 3332
 
3333 3333
 /* Line 1806 of yacc.c  */
3334
-#line 1412 "yara_grammar.y"
3334
+#line 1413 "yara_grammar.y"
3335 3335
     {
3336 3336
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3337 3337
         yr_parser_emit_pushes_for_strings(yyscanner, "$*");
... ...
@@ -3344,7 +3345,7 @@ yyreduce:
3344 3344
   case 84:
3345 3345
 
3346 3346
 /* Line 1806 of yacc.c  */
3347
-#line 1430 "yara_grammar.y"
3347
+#line 1431 "yara_grammar.y"
3348 3348
     {
3349 3349
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
3350 3350
         yr_free((yyvsp[(1) - (1)].c_string));
... ...
@@ -3354,7 +3355,7 @@ yyreduce:
3354 3354
   case 85:
3355 3355
 
3356 3356
 /* Line 1806 of yacc.c  */
3357
-#line 1435 "yara_grammar.y"
3357
+#line 1436 "yara_grammar.y"
3358 3358
     {
3359 3359
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
3360 3360
         yr_free((yyvsp[(1) - (1)].c_string));
... ...
@@ -3364,7 +3365,7 @@ yyreduce:
3364 3364
   case 87:
3365 3365
 
3366 3366
 /* Line 1806 of yacc.c  */
3367
-#line 1445 "yara_grammar.y"
3367
+#line 1446 "yara_grammar.y"
3368 3368
     {
3369 3369
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3370 3370
 #ifdef YARA_PROTO
... ...
@@ -3376,7 +3377,7 @@ yyreduce:
3376 3376
   case 88:
3377 3377
 
3378 3378
 /* Line 1806 of yacc.c  */
3379
-#line 1452 "yara_grammar.y"
3379
+#line 1453 "yara_grammar.y"
3380 3380
     {
3381 3381
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL);
3382 3382
 #ifdef YARA_PROTO
... ...
@@ -3388,7 +3389,7 @@ yyreduce:
3388 3388
   case 89:
3389 3389
 
3390 3390
 /* Line 1806 of yacc.c  */
3391
-#line 1463 "yara_grammar.y"
3391
+#line 1464 "yara_grammar.y"
3392 3392
     {
3393 3393
         (yyval.expression_type) = (yyvsp[(2) - (3)].expression_type);
3394 3394
       }
... ...
@@ -3397,7 +3398,7 @@ yyreduce:
3397 3397
   case 90:
3398 3398
 
3399 3399
 /* Line 1806 of yacc.c  */
3400
-#line 1467 "yara_grammar.y"
3400
+#line 1468 "yara_grammar.y"
3401 3401
     {
3402 3402
         compiler->last_result = yr_parser_emit(
3403 3403
             yyscanner, OP_FILESIZE, NULL);
... ...
@@ -3411,7 +3412,7 @@ yyreduce:
3411 3411
   case 91:
3412 3412
 
3413 3413
 /* Line 1806 of yacc.c  */
3414
-#line 1476 "yara_grammar.y"
3414
+#line 1477 "yara_grammar.y"
3415 3415
     {
3416 3416
 #ifndef YARA_PROTO
3417 3417
         yywarning(yyscanner,
... ...
@@ -3431,7 +3432,7 @@ yyreduce:
3431 3431
   case 92:
3432 3432
 
3433 3433
 /* Line 1806 of yacc.c  */
3434
-#line 1491 "yara_grammar.y"
3434
+#line 1492 "yara_grammar.y"
3435 3435
     {
3436 3436
         CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int8");
3437 3437
 
... ...
@@ -3447,7 +3448,7 @@ yyreduce:
3447 3447
   case 93:
3448 3448
 
3449 3449
 /* Line 1806 of yacc.c  */
3450
-#line 1502 "yara_grammar.y"
3450
+#line 1503 "yara_grammar.y"
3451 3451
     {
3452 3452
         CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int16");
3453 3453
 
... ...
@@ -3463,7 +3464,7 @@ yyreduce:
3463 3463
   case 94:
3464 3464
 
3465 3465
 /* Line 1806 of yacc.c  */
3466
-#line 1513 "yara_grammar.y"
3466
+#line 1514 "yara_grammar.y"
3467 3467
     {
3468 3468
         CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int32");
3469 3469
 
... ...
@@ -3479,7 +3480,7 @@ yyreduce:
3479 3479
   case 95:
3480 3480
 
3481 3481
 /* Line 1806 of yacc.c  */
3482
-#line 1524 "yara_grammar.y"
3482
+#line 1525 "yara_grammar.y"
3483 3483
     {
3484 3484
         CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint8");
3485 3485
 
... ...
@@ -3495,7 +3496,7 @@ yyreduce:
3495 3495
   case 96:
3496 3496
 
3497 3497
 /* Line 1806 of yacc.c  */
3498
-#line 1535 "yara_grammar.y"
3498
+#line 1536 "yara_grammar.y"
3499 3499
     {
3500 3500
         CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint16");
3501 3501
 
... ...
@@ -3511,7 +3512,7 @@ yyreduce:
3511 3511
   case 97:
3512 3512
 
3513 3513
 /* Line 1806 of yacc.c  */
3514
-#line 1546 "yara_grammar.y"
3514
+#line 1547 "yara_grammar.y"
3515 3515
     {
3516 3516
         CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint32");
3517 3517
 
... ...
@@ -3527,7 +3528,7 @@ yyreduce:
3527 3527
   case 98:
3528 3528
 
3529 3529
 /* Line 1806 of yacc.c  */
3530
-#line 1557 "yara_grammar.y"
3530
+#line 1558 "yara_grammar.y"
3531 3531
     {
3532 3532
         compiler->last_result = yr_parser_emit_with_arg(
3533 3533
             yyscanner, OP_PUSH, (yyvsp[(1) - (1)].integer), NULL);
... ...
@@ -3541,7 +3542,7 @@ yyreduce:
3541 3541
   case 99:
3542 3542
 
3543 3543
 /* Line 1806 of yacc.c  */
3544
-#line 1566 "yara_grammar.y"
3544
+#line 1567 "yara_grammar.y"
3545 3545
     {
3546 3546
         SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
3547 3547
         char* string;
... ...
@@ -3571,7 +3572,7 @@ yyreduce:
3571 3571
   case 100:
3572 3572
 
3573 3573
 /* Line 1806 of yacc.c  */
3574
-#line 1591 "yara_grammar.y"
3574
+#line 1592 "yara_grammar.y"
3575 3575
     {
3576 3576
         compiler->last_result = yr_parser_reduce_string_identifier(
3577 3577
             yyscanner,
... ...
@@ -3589,7 +3590,7 @@ yyreduce:
3589 3589
   case 101:
3590 3590
 
3591 3591
 /* Line 1806 of yacc.c  */
3592
-#line 1604 "yara_grammar.y"
3592
+#line 1605 "yara_grammar.y"
3593 3593
     {
3594 3594
         compiler->last_result = yr_parser_reduce_string_identifier(
3595 3595
             yyscanner,
... ...
@@ -3609,7 +3610,7 @@ yyreduce:
3609 3609
   case 102:
3610 3610
 
3611 3611
 /* Line 1806 of yacc.c  */
3612
-#line 1619 "yara_grammar.y"
3612
+#line 1620 "yara_grammar.y"
3613 3613
     {
3614 3614
         compiler->last_result = yr_parser_emit_with_arg(
3615 3615
             yyscanner,
... ...
@@ -3636,7 +3637,7 @@ yyreduce:
3636 3636
   case 103:
3637 3637
 
3638 3638
 /* Line 1806 of yacc.c  */
3639
-#line 1641 "yara_grammar.y"
3639
+#line 1642 "yara_grammar.y"
3640 3640
     {
3641 3641
         if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -1)  // loop identifier
3642 3642
         {
... ...
@@ -3676,7 +3677,7 @@ yyreduce:
3676 3676
   case 104:
3677 3677
 
3678 3678
 /* Line 1806 of yacc.c  */
3679
-#line 1676 "yara_grammar.y"
3679
+#line 1677 "yara_grammar.y"
3680 3680
     {
3681 3681
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+");
3682 3682
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+");
... ...
@@ -3690,7 +3691,7 @@ yyreduce:
3690 3690
   case 105:
3691 3691
 
3692 3692
 /* Line 1806 of yacc.c  */
3693
-#line 1685 "yara_grammar.y"
3693
+#line 1686 "yara_grammar.y"
3694 3694
     {
3695 3695
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-");
3696 3696
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-");
... ...
@@ -3704,7 +3705,7 @@ yyreduce:
3704 3704
   case 106:
3705 3705
 
3706 3706
 /* Line 1806 of yacc.c  */
3707
-#line 1694 "yara_grammar.y"
3707
+#line 1695 "yara_grammar.y"
3708 3708
     {
3709 3709
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*");
3710 3710
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*");
... ...
@@ -3718,7 +3719,7 @@ yyreduce:
3718 3718
   case 107:
3719 3719
 
3720 3720
 /* Line 1806 of yacc.c  */
3721
-#line 1703 "yara_grammar.y"
3721
+#line 1704 "yara_grammar.y"
3722 3722
     {
3723 3723
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
3724 3724
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
... ...
@@ -3732,7 +3733,7 @@ yyreduce:
3732 3732
   case 108:
3733 3733
 
3734 3734
 /* Line 1806 of yacc.c  */
3735
-#line 1712 "yara_grammar.y"
3735
+#line 1713 "yara_grammar.y"
3736 3736
     {
3737 3737
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%");
3738 3738
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%");
... ...
@@ -3746,7 +3747,7 @@ yyreduce:
3746 3746
   case 109:
3747 3747
 
3748 3748
 /* Line 1806 of yacc.c  */
3749
-#line 1721 "yara_grammar.y"
3749
+#line 1722 "yara_grammar.y"
3750 3750
     {
3751 3751
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3752 3752
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
... ...
@@ -3760,7 +3761,7 @@ yyreduce:
3760 3760
   case 110:
3761 3761
 
3762 3762
 /* Line 1806 of yacc.c  */
3763
-#line 1730 "yara_grammar.y"
3763
+#line 1731 "yara_grammar.y"
3764 3764
     {
3765 3765
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3766 3766
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
... ...
@@ -3774,7 +3775,7 @@ yyreduce:
3774 3774
   case 111:
3775 3775
 
3776 3776
 /* Line 1806 of yacc.c  */
3777
-#line 1739 "yara_grammar.y"
3777
+#line 1740 "yara_grammar.y"
3778 3778
     {
3779 3779
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|");
3780 3780
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|");
... ...
@@ -3788,7 +3789,7 @@ yyreduce:
3788 3788
   case 112:
3789 3789
 
3790 3790
 /* Line 1806 of yacc.c  */
3791
-#line 1748 "yara_grammar.y"
3791
+#line 1749 "yara_grammar.y"
3792 3792
     {
3793 3793
         CHECK_TYPE((yyvsp[(2) - (2)].expression_type), EXPRESSION_TYPE_INTEGER, "~");
3794 3794
 
... ...
@@ -3801,7 +3802,7 @@ yyreduce:
3801 3801
   case 113:
3802 3802
 
3803 3803
 /* Line 1806 of yacc.c  */
3804
-#line 1756 "yara_grammar.y"
3804
+#line 1757 "yara_grammar.y"
3805 3805
     {
3806 3806
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
3807 3807
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
... ...
@@ -3815,7 +3816,7 @@ yyreduce:
3815 3815
   case 114:
3816 3816
 
3817 3817
 /* Line 1806 of yacc.c  */
3818
-#line 1765 "yara_grammar.y"
3818
+#line 1766 "yara_grammar.y"
3819 3819
     {
3820 3820
         CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
3821 3821
         CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
... ...
@@ -3829,7 +3830,7 @@ yyreduce:
3829 3829
   case 115:
3830 3830
 
3831 3831
 /* Line 1806 of yacc.c  */
3832
-#line 1774 "yara_grammar.y"
3832
+#line 1775 "yara_grammar.y"
3833 3833
     {
3834 3834
         (yyval.expression_type) = (yyvsp[(1) - (1)].expression_type);
3835 3835
       }
... ...
@@ -3838,7 +3839,7 @@ yyreduce:
3838 3838
 
3839 3839
 
3840 3840
 /* Line 1806 of yacc.c  */
3841
-#line 3842 "yara_grammar.c"
3841
+#line 3843 "yara_grammar.c"
3842 3842
       default: break;
3843 3843
     }
3844 3844
   /* User semantic actions sometimes alter yychar, and that requires
... ...
@@ -4069,6 +4070,6 @@ yyreturn:
4069 4069
 
4070 4070
 
4071 4071
 /* Line 2067 of yacc.c  */
4072
-#line 1779 "yara_grammar.y"
4072
+#line 1780 "yara_grammar.y"
4073 4073
 
4074 4074
 
... ...
@@ -151,7 +151,7 @@ typedef union YYSTYPE
151 151
 {
152 152
 
153 153
 /* Line 2068 of yacc.c  */
154
-#line 213 "yara_grammar.y"
154
+#line 214 "yara_grammar.y"
155 155
 
156 156
   SIZED_STRING*   sized_string;
157 157
   char*           c_string;
... ...
@@ -62,6 +62,7 @@ limitations under the License.
62 62
 #include "libclamav/yara_grammar.h"
63 63
 #include "libclamav/yara_lexer.h"
64 64
 #include "libclamav/yara_parser.h"
65
+#include "libclamav/yara_exec.h"
65 66
 #endif
66 67
 
67 68
 #define YYERROR_VERBOSE
... ...
@@ -17,8 +17,8 @@ limitations under the License.
17 17
 #include <stdint.h>
18 18
 #include <string.h>
19 19
 
20
-#include "yara_clam.h"
21 20
 #include <yara_hash.h>
21
+#include "yara_clam.h"
22 22
 #if REAL_YARA
23 23
 #include <yara/mem.h>
24 24
 #include <yara/error.h>
... ...
@@ -3039,15 +3039,11 @@ void yyerror(
3039 3039
 #else
3040 3040
   compiler->errors++;
3041 3041
   if (error_message != NULL)
3042
-    cli_errmsg("yara_lexer:yyerror() %s\n", error_message);
3043
-  else if (compiler->error_msg != NULL)
3044
-    cli_errmsg("yara_lexer:yyerror() %s\n", compiler->error_msg);
3045
-  else if (compiler->last_error_extra_info[0] != (char) 0)
3046
-    cli_errmsg("yara_lexer:yyerror() %s\n", compiler->last_error_extra_info);
3047
-  else
3048
-    cli_errmsg("yara_lexer:yyerror() error unknown\n");
3049
-  if (compiler->last_result != ERROR_SUCCESS)
3050
-    cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result);
3042
+    cli_errmsg("yara_lexer:yyerror() error message: %s\n", error_message);
3043
+  if (compiler->error_msg != NULL)
3044
+    cli_errmsg("yara_lexer:yyerror() compiler error message: %s\n", compiler->error_msg);
3045
+  if (compiler->last_error_extra_info[0] != (char) 0)
3046
+    cli_errmsg("yara_lexer:yyerror() error extra info: %s\n", compiler->last_error_extra_info);
3051 3047
   if (compiler->last_result != ERROR_SUCCESS)
3052 3048
     cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result);
3053 3049
   if (compiler->error_line != 0)
... ...
@@ -705,15 +705,11 @@ void yyerror(
705 705
 #else
706 706
   compiler->errors++;
707 707
   if (error_message != NULL)
708
-    cli_errmsg("yara_lexer:yyerror() %s\n", error_message);
709
-  else if (compiler->error_msg != NULL)
710
-    cli_errmsg("yara_lexer:yyerror() %s\n", compiler->error_msg);
711
-  else if (compiler->last_error_extra_info[0] != (char) 0)
712
-    cli_errmsg("yara_lexer:yyerror() %s\n", compiler->last_error_extra_info);
713
-  else
714
-    cli_errmsg("yara_lexer:yyerror() error unknown\n");
715
-  if (compiler->last_result != ERROR_SUCCESS)
716
-    cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result);
708
+    cli_errmsg("yara_lexer:yyerror() error message: %s\n", error_message);
709
+  if (compiler->error_msg != NULL)
710
+    cli_errmsg("yara_lexer:yyerror() compiler error message: %s\n", compiler->error_msg);
711
+  if (compiler->last_error_extra_info[0] != (char) 0)
712
+    cli_errmsg("yara_lexer:yyerror() error extra info: %s\n", compiler->last_error_extra_info);
717 713
   if (compiler->last_result != ERROR_SUCCESS)
718 714
     cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result);
719 715
   if (compiler->error_line != 0)
... ...
@@ -55,6 +55,7 @@ limitations under the License.
55 55
 #include "yara_clam.h"
56 56
 #include "yara_grammar.h"
57 57
 #include "yara_lexer.h"
58
+#include "yara_exec.h"
58 59
 #include "others.h"
59 60
 #endif
60 61
 
... ...
@@ -811,8 +812,9 @@ int yr_parser_reduce_rule_declaration(
811 811
   //Yara condition code will work OK as long as it is less than 64K.
812 812
   //FAIL_ON_COMPILER_ERROR(yr_arena_coalesce(compiler->code_arena));
813 813
   rule->code_start = yr_arena_base_address(compiler->code_arena);
814
-  compiler->code_arena->page_list_head->address = NULL;
815
-  yr_arena_destroy(compiler->code_arena);
814
+  yr_arena_append(compiler->the_arena, compiler->code_arena);
815
+  //  compiler->code_arena->page_list_head->address = NULL;
816
+  //  yr_arena_destroy(compiler->code_arena);
816 817
   FAIL_ON_COMPILER_ERROR(yr_arena_create(65536, 0, &compiler->code_arena));
817 818
   STAILQ_INSERT_TAIL(&compiler->rule_q, rule, link); 
818 819
 #endif