[Forensics-changes] [yara] 316/407: Add support for negative numbers

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:40 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 5b117b6a83429bcaca15a97bcb4292ac58185ca0
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Mon Jan 5 13:17:18 2015 +0100

    Add support for negative numbers
---
 libyara/lexer.c           | 387 +++++++++++++++++++++++-----------------------
 libyara/lexer.l           |   4 +-
 yara-python/tests.py      |   6 +-
 yara-python/yara-python.c |   4 +-
 4 files changed, 203 insertions(+), 198 deletions(-)

diff --git a/libyara/lexer.c b/libyara/lexer.c
index fe2c5f2..8764ba9 100644
--- a/libyara/lexer.c
+++ b/libyara/lexer.c
@@ -47,7 +47,6 @@ typedef int16_t flex_int16_t;
 typedef uint16_t flex_uint16_t;
 typedef int32_t flex_int32_t;
 typedef uint32_t flex_uint32_t;
-typedef uint64_t flex_uint64_t;
 #else
 typedef signed char flex_int8_t;
 typedef short int flex_int16_t;
@@ -358,7 +357,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
  */
 #define YY_DO_BEFORE_ACTION \
 	yyg->yytext_ptr = yy_bp; \
-	yyleng = (yy_size_t) (yy_cp - yy_bp); \
+	yyleng = (size_t) (yy_cp - yy_bp); \
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
@@ -372,32 +371,32 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static yyconst flex_int16_t yy_accept[215] =
+static yyconst flex_int16_t yy_accept[216] =
     {   0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-       72,   70,   69,   69,   70,   66,   45,   44,   67,   49,
-       49,    1,   70,    2,   46,   48,   48,   48,   48,   48,
+       72,   70,   69,   69,   70,   66,   45,   44,   70,   67,
+       49,   49,    1,   70,    2,   46,   48,   48,   48,   48,
        48,   48,   48,   48,   48,   48,   48,   48,   48,   48,
-       48,   70,   58,   59,   52,   71,   64,   65,   61,   71,
-       41,   42,   38,   38,    6,   45,   43,   44,   36,   39,
-        0,   49,    0,    0,    0,    7,    3,    5,    4,    8,
-       46,   48,   48,   48,   48,   24,   48,   48,   48,   48,
-       48,   48,   48,   48,   25,   48,   48,   48,   26,   23,
-       48,   48,   48,   48,   48,   48,   48,    0,   58,   60,
-
-       55,   56,   54,   53,   60,   64,   61,   61,   63,   62,
-       41,   37,   39,   50,   49,   51,   29,   22,   30,   48,
-       48,   48,   48,   48,   28,   48,   48,   48,   48,   48,
-       48,   48,   48,   21,   48,   48,   48,   48,   48,   48,
-       48,   68,    0,   48,   48,   48,   48,   48,   48,   48,
-       48,   48,   48,   48,   48,   47,   48,   12,   48,   48,
-       11,   48,   27,   19,   15,   57,   14,   48,   48,   48,
-       20,   48,   48,   48,   48,   48,   48,   48,   48,   48,
-       48,   48,   48,   48,   48,   48,   10,   35,   48,   47,
-       48,   17,   48,   48,   48,   48,   48,   48,   48,   48,
-
-       33,    9,   13,   48,   34,   48,   32,   16,    0,   18,
-       48,   40,   31,    0
+       48,   48,   70,   58,   59,   52,   71,   64,   65,   61,
+       71,   41,   42,   38,   38,    6,   45,   43,   44,   49,
+       36,   39,    0,    0,    0,    0,    7,    3,    5,    4,
+        8,   46,   48,   48,   48,   48,   24,   48,   48,   48,
+       48,   48,   48,   48,   48,   25,   48,   48,   48,   26,
+       23,   48,   48,   48,   48,   48,   48,   48,    0,   58,
+
+       60,   55,   56,   54,   53,   60,   64,   61,   61,   63,
+       62,   41,   37,   39,   50,   49,   51,   29,   22,   30,
+       48,   48,   48,   48,   48,   28,   48,   48,   48,   48,
+       48,   48,   48,   48,   21,   48,   48,   48,   48,   48,
+       48,   48,   68,    0,   48,   48,   48,   48,   48,   48,
+       48,   48,   48,   48,   48,   48,   47,   48,   12,   48,
+       48,   11,   48,   27,   19,   15,   57,   14,   48,   48,
+       48,   20,   48,   48,   48,   48,   48,   48,   48,   48,
+       48,   48,   48,   48,   48,   48,   48,   10,   35,   48,
+       47,   48,   17,   48,   48,   48,   48,   48,   48,   48,
+
+       48,   33,    9,   13,   48,   34,   48,   32,   16,    0,
+       18,   48,   40,   31,    0
     } ;
 
 static yyconst flex_int32_t yy_ec[256] =
@@ -406,16 +405,16 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    2,    5,    6,    7,    8,    1,    1,    1,    9,
-        9,   10,    1,    1,    9,   11,   12,   13,   14,   15,
-       16,   17,   17,   18,   17,   19,   17,    1,    1,   20,
-       21,   22,    9,   23,   24,   25,   24,   24,   24,   24,
-       26,   26,   26,   26,   27,   26,   28,   26,   26,   26,
-       26,   26,   26,   26,   26,   26,   26,   26,   26,   26,
-        9,   29,    9,    1,   30,    1,   31,   32,   33,   34,
-
-       35,   36,   37,   38,   39,   26,   26,   40,   41,   42,
-       43,   44,   26,   45,   46,   47,   48,   49,   50,   51,
-       52,   53,   54,    9,   55,    1,    1,    1,    1,    1,
+        9,   10,    1,    1,   11,   12,   13,   14,   15,   16,
+       17,   18,   18,   19,   18,   20,   18,    1,    1,   21,
+       22,   23,    9,   24,   25,   26,   25,   25,   25,   25,
+       27,   27,   27,   27,   28,   27,   29,   27,   27,   27,
+       27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
+        9,   30,    9,    1,   31,    1,   32,   33,   34,   35,
+
+       36,   37,   38,   39,   40,   27,   27,   41,   42,   43,
+       44,   45,   27,   46,   47,   48,   49,   50,   51,   52,
+       53,   54,   55,    9,   56,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -432,178 +431,180 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst flex_int32_t yy_meta[56] =
+static yyconst flex_int32_t yy_meta[57] =
     {   0,
         1,    2,    3,    1,    1,    4,    1,    1,    2,    5,
-        6,    7,    8,    8,    8,    8,    8,    8,    8,    1,
-        1,    1,    1,    9,    9,   10,   11,   11,   12,   10,
-        9,    9,    9,    9,    9,    9,   10,   10,   10,   10,
+        2,    6,    7,    8,    8,    8,    8,    8,    8,    8,
+        1,    1,    1,    1,    9,    9,   10,   11,   11,   12,
+       10,    9,    9,    9,    9,    9,    9,   10,   10,   10,
        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
-       11,   10,   10,    1,    1
+       10,   11,   10,   10,    1,    1
     } ;
 
-static yyconst flex_int16_t yy_base[234] =
+static yyconst flex_int16_t yy_base[235] =
     {   0,
-        0,    0,   53,   54,   55,   58,  375,  374,  369,  368,
-      377,  382,  382,  382,  355,  382,    0,  365,   52,   52,
-       58,   45,  353,   50,    0,    0,   48,  330,  330,   50,
-      331,   32,   61,  327,   32,  324,  320,  320,   59,  327,
-      326,    0,    0,  382,  382,   70,    0,  382,   61,  352,
-        0,  382,  382,  351,  382,    0,  382,  352,  382,    0,
-      109,    0,  336,  335,    0,  382,  382,  382,  382,  382,
-        0,    0,  319,   67,  325,    0,  315,  309,  315,  314,
-      308,  312,  308,  306,   58,  302,  301,   69,    0,    0,
-      308,  306,  300,  309,  295,  300,  307,  285,    0,  382,
-
-      382,  382,  382,  382,    0,    0,  293,  382,  382,  382,
-        0,  382,    0,  116,  382,    0,    0,    0,    0,  299,
-      102,  292,  290,  300,    0,  294,  301,  289,  291,   92,
-      297,  298,  297,    0,  278,  291,  286,  283,  288,  275,
-      286,  382,    0,  281,  280,  287,  265,  281,  269,  264,
-      282,  267,  263,  292,  294,  276,  269,    0,  245,  249,
-        0,  225,    0,    0,    0,  382,    0,  213,  217,  190,
-        0,  194,  185,  187,  179,  191,  178,  177,  175,  157,
-      166,  109,  105,  103,   92,   99,    0,    0,  108,    0,
-       96,    0,  106,   94,   96,   92,   98,   85,   84,  113,
-
-        0,    0,    0,   71,    0,   36,    0,    0,  108,    0,
-       28,  382,    0,  382,  149,  161,  173,  185,  190,  197,
-      203,  207,  211,  221,  230,  241,  253,  264,  276,  288,
-      293,  295,  297
+        0,    0,   54,   55,   56,   59,  383,  382,  377,  376,
+      385,  390,  390,  390,  362,  390,    0,  373,   59,   53,
+       52,   59,   46,  360,   60,    0,    0,   49,  337,  337,
+       59,  338,   51,   66,  334,   63,  331,  327,  327,   66,
+      334,  333,    0,    0,  390,  390,   89,    0,  390,   66,
+      359,    0,  390,  390,  358,  390,    0,  390,  360,    0,
+      390,    0,  106,  343,  342,    0,  390,  390,  390,  390,
+      390,    0,    0,  326,   75,  332,    0,  322,  316,  322,
+      321,  315,  319,  315,  313,   67,  309,  308,   82,    0,
+        0,  315,  313,  307,  316,  302,  307,  314,  292,    0,
+
+      390,  390,  390,  390,  390,    0,    0,  300,  390,  390,
+      390,    0,  390,    0,  128,  390,    0,    0,    0,    0,
+      306,   79,  299,  297,  307,    0,  301,  308,  296,  298,
+      114,  304,  305,  304,    0,  285,  298,  293,  290,  295,
+      282,  293,  390,    0,  288,  287,  294,  272,  288,  276,
+      271,  289,  274,  270,  299,  301,  283,  276,    0,  267,
+      281,    0,  269,    0,    0,    0,  390,    0,  263,  270,
+      264,    0,  268,  263,  265,  242,  244,  230,  223,  219,
+      185,  194,  187,  183,  181,  170,  166,    0,    0,  175,
+        0,  162,    0,  167,  155,   96,   91,   96,   97,   83,
+
+      115,    0,    0,    0,   64,    0,   27,    0,    0,  133,
+        0,   17,  390,    0,  390,  148,  160,  172,  184,  189,
+      196,  202,  206,  210,  220,  229,  240,  252,  263,  275,
+      287,  292,  294,  296
     } ;
 
-static yyconst flex_int16_t yy_def[234] =
+static yyconst flex_int16_t yy_def[235] =
     {   0,
-      214,    1,  215,  215,  216,  216,  217,  217,  218,  218,
-      214,  214,  214,  214,  214,  214,  219,  220,  214,  221,
-      221,  214,  214,  214,  222,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  224,  225,  214,  214,  226,  227,  214,  214,  228,
-      229,  214,  214,  214,  214,  219,  214,  220,  214,  230,
-      214,   21,  214,  214,  231,  214,  214,  214,  214,  214,
-      222,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  224,  225,  214,
-
-      214,  214,  214,  214,  232,  227,  214,  214,  214,  214,
-      229,  214,  230,  214,  214,  231,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  214,  233,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  214,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
-
-      223,  223,  223,  223,  223,  223,  223,  223,  214,  223,
-      223,  214,  223,    0,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214
+      215,    1,  216,  216,  217,  217,  218,  218,  219,  219,
+      215,  215,  215,  215,  215,  215,  220,  221,  215,  215,
+      222,  222,  215,  215,  215,  223,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  225,  226,  215,  215,  227,  228,  215,  215,
+      229,  230,  215,  215,  215,  215,  220,  215,  221,   22,
+      215,  231,  215,  215,  215,  232,  215,  215,  215,  215,
+      215,  223,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  225,  226,
+
+      215,  215,  215,  215,  215,  233,  228,  215,  215,  215,
+      215,  230,  215,  231,  215,  215,  232,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  215,  234,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  215,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  224,
+
+      224,  224,  224,  224,  224,  224,  224,  224,  224,  215,
+      224,  224,  215,  224,    0,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215
     } ;
 
-static yyconst flex_int16_t yy_nxt[438] =
+static yyconst flex_int16_t yy_nxt[447] =
     {   0,
        12,   13,   14,   13,   15,   16,   17,   18,   12,   12,
-       12,   19,   20,   21,   21,   21,   21,   21,   21,   22,
-       23,   24,   25,   26,   26,   26,   26,   26,   12,   26,
-       27,   26,   28,   26,   29,   30,   31,   26,   32,   26,
-       33,   34,   35,   36,   37,   38,   39,   40,   26,   41,
-       26,   26,   26,   42,   12,   44,   44,   48,   45,   45,
-       48,   59,   61,   60,   66,   67,   49,   89,   61,   49,
-       69,   70,   84,   85,  213,  101,   90,  211,   63,   64,
-       79,   46,   46,   50,   63,   64,   50,   73,   80,   74,
-      129,   86,   81,   75,   76,   87,   94,   82,  102,  107,
-
-      118,  133,   65,   95,  130,  154,  108,  155,  214,  209,
-      156,  103,  210,  212,  209,  134,  104,  208,  119,  207,
-      105,  114,  114,  114,  114,  114,  114,  114,  114,  114,
-      114,  114,  114,  114,  114,  145,  206,  205,  204,  203,
-      202,  201,  200,  199,  198,  197,  196,  195,  146,   43,
-       43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
-       43,   47,   47,   47,   47,   47,   47,   47,   47,   47,
-       47,   47,   47,   51,   51,   51,   51,   51,   51,   51,
-       51,   51,   51,   51,   51,   53,   53,   53,   53,   53,
-       53,   53,   53,   53,   53,   53,   53,   56,   56,   56,
-
-       56,   58,  194,  193,   58,   58,   58,   58,   62,  192,
-       62,  191,  190,   62,   71,   71,   71,   71,   72,   72,
-       72,   72,   98,   98,  189,  188,  187,  186,   98,   98,
-       99,   99,  185,  184,   99,   99,   99,   99,   99,   99,
-       99,  100,  100,  100,  100,  100,  100,  100,  100,  100,
-      100,  100,  100,  106,  106,  183,  106,  106,  106,  182,
-      106,  106,  106,  106,  109,  109,  181,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  111,  111,  111,  180,
-      111,  111,  111,  111,  111,  111,  111,  111,  113,  113,
-      179,  113,  113,  113,  113,  113,  113,  113,  113,  113,
-
-      116,  116,  143,  143,  166,  166,  178,  177,  156,  156,
-      176,  175,  174,  173,  172,  171,  170,  169,  168,  167,
-      165,  130,  164,  163,  162,  161,  160,  159,  158,  157,
-      153,  152,  151,  150,  149,  148,  147,  144,  108,  142,
-      141,  140,  139,  138,  137,  136,  135,  132,  131,  128,
-      127,  126,  125,  124,  123,  122,  121,  120,  117,  115,
-      115,   57,  112,  110,   97,   96,   93,   92,   91,   88,
-       83,   78,   77,   68,   57,   55,  214,   54,   54,   52,
-       52,   11,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214
+       19,   12,   20,   21,   22,   22,   22,   22,   22,   22,
+       23,   24,   25,   26,   27,   27,   27,   27,   27,   12,
+       27,   28,   27,   29,   27,   30,   31,   32,   27,   33,
+       27,   34,   35,   36,   37,   38,   39,   40,   41,   27,
+       42,   27,   27,   27,   43,   12,   45,   45,   49,   46,
+       46,   49,   61,   63,  214,   62,   67,   68,   50,  212,
+       63,   50,   60,   60,   60,   60,   60,   60,   60,   64,
+       65,   70,   71,   47,   47,   51,   64,   65,   51,   74,
+       80,   75,   85,   86,  102,   76,   77,   87,   81,   90,
+
+      130,   88,   82,   66,   95,  108,  211,   83,   91,  119,
+      215,   96,  109,  146,  131,  134,  210,  209,  103,  115,
+      115,  115,  115,  115,  115,  115,  147,  120,  155,  135,
+      156,  104,  208,  157,  210,  207,  105,  206,  213,  205,
+      106,  115,  115,  115,  115,  115,  115,  115,   44,   44,
+       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
+       48,   48,   48,   48,   48,   48,   48,   48,   48,   48,
+       48,   48,   52,   52,   52,   52,   52,   52,   52,   52,
+       52,   52,   52,   52,   54,   54,   54,   54,   54,   54,
+       54,   54,   54,   54,   54,   54,   57,   57,   57,   57,
+
+       59,  204,  203,   59,   59,   59,   59,   60,  202,   60,
+      201,  200,   60,   72,   72,   72,   72,   73,   73,   73,
+       73,   99,   99,  199,  198,  197,  196,   99,   99,  100,
+      100,  195,  194,  100,  100,  100,  100,  100,  100,  100,
+      101,  101,  101,  101,  101,  101,  101,  101,  101,  101,
+      101,  101,  107,  107,  193,  107,  107,  107,  192,  107,
+      107,  107,  107,  110,  110,  191,  110,  110,  110,  110,
+      110,  110,  110,  110,  110,  112,  112,  112,  190,  112,
+      112,  112,  112,  112,  112,  112,  112,  114,  114,  189,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  117,
+
+      117,  144,  144,  167,  167,  188,  187,  186,  185,  184,
+      183,  182,  181,  180,  179,  178,  157,  157,  177,  176,
+      175,  174,  173,  172,  171,  170,  169,  168,  166,  131,
+      165,  164,  163,  162,  161,  160,  159,  158,  154,  153,
+      152,  151,  150,  149,  148,  145,  109,  143,  142,  141,
+      140,  139,  138,  137,  136,  133,  132,  129,  128,  127,
+      126,  125,  124,  123,  122,  121,  118,  116,  116,   58,
+      113,  111,   98,   97,   94,   93,   92,   89,   84,   79,
+       78,   69,   58,   56,  215,   55,   55,   53,   53,   11,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215
     } ;
 
-static yyconst flex_int16_t yy_chk[438] =
+static yyconst flex_int16_t yy_chk[447] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    3,    4,    5,    3,    4,
-        6,   19,   20,   19,   22,   22,    5,   35,   21,    6,
-       24,   24,   32,   32,  211,   46,   35,  206,   20,   20,
-       30,    3,    4,    5,   21,   21,    6,   27,   30,   27,
-       85,   33,   30,   27,   27,   33,   39,   30,   46,   49,
-
-       74,   88,   20,   39,   85,  130,   49,  130,   21,  209,
-      130,   46,  204,  209,  200,   88,   46,  199,   74,  198,
-       46,   61,   61,   61,   61,   61,   61,   61,  114,  114,
-      114,  114,  114,  114,  114,  121,  197,  196,  195,  194,
-      193,  191,  189,  186,  185,  184,  183,  182,  121,  215,
+        1,    1,    1,    1,    1,    1,    3,    4,    5,    3,
+        4,    6,   20,   21,  212,   20,   23,   23,    5,  207,
+       22,    6,   19,   19,   19,   19,   19,   19,   19,   21,
+       21,   25,   25,    3,    4,    5,   22,   22,    6,   28,
+       31,   28,   33,   33,   47,   28,   28,   34,   31,   36,
+
+       86,   34,   31,   21,   40,   50,  205,   31,   36,   75,
+       22,   40,   50,  122,   86,   89,  201,  200,   47,   63,
+       63,   63,   63,   63,   63,   63,  122,   75,  131,   89,
+      131,   47,  199,  131,  210,  198,   47,  197,  210,  196,
+       47,  115,  115,  115,  115,  115,  115,  115,  216,  216,
+      216,  216,  216,  216,  216,  216,  216,  216,  216,  216,
+      217,  217,  217,  217,  217,  217,  217,  217,  217,  217,
+      217,  217,  218,  218,  218,  218,  218,  218,  218,  218,
+      218,  218,  218,  218,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  220,  220,  220,  220,
+
+      221,  195,  194,  221,  221,  221,  221,  222,  192,  222,
+      190,  187,  222,  223,  223,  223,  223,  224,  224,  224,
+      224,  225,  225,  186,  185,  184,  183,  225,  225,  226,
+      226,  182,  181,  226,  226,  226,  226,  226,  226,  226,
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
+      227,  227,  228,  228,  180,  228,  228,  228,  179,  228,
+      228,  228,  228,  229,  229,  178,  229,  229,  229,  229,
+      229,  229,  229,  229,  229,  230,  230,  230,  177,  230,
+      230,  230,  230,  230,  230,  230,  230,  231,  231,  176,
+      231,  231,  231,  231,  231,  231,  231,  231,  231,  232,
+
+      232,  233,  233,  234,  234,  175,  174,  173,  171,  170,
+      169,  163,  161,  160,  158,  157,  156,  155,  154,  153,
+      152,  151,  150,  149,  148,  147,  146,  145,  142,  141,
+      140,  139,  138,  137,  136,  134,  133,  132,  130,  129,
+      128,  127,  125,  124,  123,  121,  108,   99,   98,   97,
+       96,   95,   94,   93,   92,   88,   87,   85,   84,   83,
+       82,   81,   80,   79,   78,   76,   74,   65,   64,   59,
+       55,   51,   42,   41,   39,   38,   37,   35,   32,   30,
+       29,   24,   18,   15,   11,   10,    9,    8,    7,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
+      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
       215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
-      215,  216,  216,  216,  216,  216,  216,  216,  216,  216,
-      216,  216,  216,  217,  217,  217,  217,  217,  217,  217,
-      217,  217,  217,  217,  217,  218,  218,  218,  218,  218,
-      218,  218,  218,  218,  218,  218,  218,  219,  219,  219,
-
-      219,  220,  181,  180,  220,  220,  220,  220,  221,  179,
-      221,  178,  177,  221,  222,  222,  222,  222,  223,  223,
-      223,  223,  224,  224,  176,  175,  174,  173,  224,  224,
-      225,  225,  172,  170,  225,  225,  225,  225,  225,  225,
-      225,  226,  226,  226,  226,  226,  226,  226,  226,  226,
-      226,  226,  226,  227,  227,  169,  227,  227,  227,  168,
-      227,  227,  227,  227,  228,  228,  162,  228,  228,  228,
-      228,  228,  228,  228,  228,  228,  229,  229,  229,  160,
-      229,  229,  229,  229,  229,  229,  229,  229,  230,  230,
-      159,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-
-      231,  231,  232,  232,  233,  233,  157,  156,  155,  154,
-      153,  152,  151,  150,  149,  148,  147,  146,  145,  144,
-      141,  140,  139,  138,  137,  136,  135,  133,  132,  131,
-      129,  128,  127,  126,  124,  123,  122,  120,  107,   98,
-       97,   96,   95,   94,   93,   92,   91,   87,   86,   84,
-       83,   82,   81,   80,   79,   78,   77,   75,   73,   64,
-       63,   58,   54,   50,   41,   40,   38,   37,   36,   34,
-       31,   29,   28,   23,   18,   15,   11,   10,    9,    8,
-        7,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  214,  214,  214,  214,  214,  214
+      215,  215,  215,  215,  215,  215
     } ;
 
 /* Table of booleans, true if rule could match eol. */
@@ -684,7 +685,7 @@ limitations under the License.
 
 
 
-#line 688 "lexer.c"
+#line 689 "lexer.c"
 
 #define INITIAL 0
 #define str 1
@@ -922,7 +923,7 @@ YY_DECL
 #line 83 "lexer.l"
 
 
-#line 926 "lexer.c"
+#line 927 "lexer.c"
 
     yylval = yylval_param;
 
@@ -977,13 +978,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 215 )
+				if ( yy_current_state >= 216 )
 					yy_c = yy_meta[(unsigned int) yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			++yy_cp;
 			}
-		while ( yy_current_state != 214 );
+		while ( yy_current_state != 215 );
 		yy_cp = yyg->yy_last_accepting_cpos;
 		yy_current_state = yyg->yy_last_accepting_state;
 
@@ -1754,7 +1755,7 @@ YY_RULE_SETUP
 #line 591 "lexer.l"
 ECHO;
 	YY_BREAK
-#line 1758 "lexer.c"
+#line 1759 "lexer.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -2047,7 +2048,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 215 )
+			if ( yy_current_state >= 216 )
 				yy_c = yy_meta[(unsigned int) yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -2076,11 +2077,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 215 )
+		if ( yy_current_state >= 216 )
 			yy_c = yy_meta[(unsigned int) yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-	yy_is_jam = (yy_current_state == 214);
+	yy_is_jam = (yy_current_state == 215);
 
 	return yy_is_jam ? 0 : yy_current_state;
 }
diff --git a/libyara/lexer.l b/libyara/lexer.l
index 5aa9028..ca9f4f1 100644
--- a/libyara/lexer.l
+++ b/libyara/lexer.l
@@ -375,7 +375,7 @@ u?int(8|16|32)(be)? {
 }
 
 
-{digit}+(MB|KB){0,1}  {
+-?{digit}+(MB|KB){0,1}  {
 
   yylval->integer = (size_t) atol(yytext);
 
@@ -390,7 +390,7 @@ u?int(8|16|32)(be)? {
   return _NUMBER_;
 }
 
-{digit}+"."{digit}+  {
+-?{digit}+"."{digit}+  {
   yylval->double_ = atof(yytext);
   return _DOUBLE_;
 }
diff --git a/yara-python/tests.py b/yara-python/tests.py
index 163dac9..6e26c3e 100644
--- a/yara-python/tests.py
+++ b/yara-python/tests.py
@@ -326,7 +326,11 @@ class TestYara(unittest.TestCase):
             'rule test { condition: 5 % 2 == 1 }',
             'rule test { condition: 1.5 + 1.5 == 3}',
             'rule test { condition: 3 \ 2 == 1}',
-            'rule test { condition: 3.0 \ 2 == 1.5}'
+            'rule test { condition: 3.0 \ 2 == 1.5}',
+            'rule test { condition: 1 + -1 == 0}',
+            'rule test { condition: -1 + -1 == -2}',
+            'rule test { condition: -2 * 2 == -4}',
+            'rule test { condition: -1.0 * 1 == -1.0}',
         ])
 
     def testBitwiseOperators(self):
diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index 3e58f2f..007f3f0 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -485,7 +485,7 @@ int yara_callback(
   yr_rule_metas_foreach(rule, meta)
   {
     if (meta->type == META_TYPE_INTEGER)
-      object = Py_BuildValue("I", meta->integer);
+      object = Py_BuildValue("i", meta->integer);
     else if (meta->type == META_TYPE_BOOLEAN)
       object = PyBool_FromLong(meta->integer);
     else
@@ -927,7 +927,7 @@ static PyObject * Rules_next(PyObject *self)
     yr_rule_metas_foreach(rules->iter_current_rule, meta)
     {
       if (meta->type == META_TYPE_INTEGER)
-        object = Py_BuildValue("I", meta->integer);
+        object = Py_BuildValue("i", meta->integer);
       else if (meta->type == META_TYPE_BOOLEAN)
         object = PyBool_FromLong(meta->integer);
       else

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