[Forensics-changes] [yara] 17/415: Bug fixes

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:42:38 UTC 2014


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

bengen pushed a commit to branch debian
in repository yara.

commit c5516262ddf9572cd1aecdaa254efaa995f6d6b0
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Feb 17 16:12:33 2009 +0000

    Bug fixes
---
 ChangeLog               |   5 ++
 configure.ac            |   2 +-
 libyara/ast.c           |  20 ++++++-
 libyara/error.c         |   2 -
 libyara/grammar.c       |   2 +-
 libyara/grammar.y       |   2 +-
 libyara/lex.c           | 146 ++++++++++++++++++++++++------------------------
 libyara/lex.l           |  14 ++---
 libyara/libyara.tmproj  |  22 ++++----
 yara-python/setup.py    |   2 +-
 yara-python/setupwin.py |   2 +-
 11 files changed, 119 insertions(+), 100 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b5530d6..0a89ff4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,3 +26,8 @@ version 1.2
 	* BUGFIX: Access violation when scanning MZ files with e_lfanew == -1
 	* BUGFIX: Incorrect handling of hex strings in lexer
 	
+version 1.2.1
+	* BUGFIX: Invoking pcre_compile with non-terminated string
+	* BUGFIX: Underscore (_) not recongnized in string identifiers
+	* BUGFIX: Memory leak
+	
diff --git a/configure.ac b/configure.ac
index 1190f08..a42e1e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([yara], [1.2], [vmalvarez at hispasec.com])
+AC_INIT([yara], [1.2.1], [vmalvarez at hispasec.com])
         AM_INIT_AUTOMAKE([-Wall -Werror])
         AC_PROG_CC
 		#AC_CHECK_LIB(yara,compile_rules,,AC_MSG_ERROR(yara not found))
diff --git a/libyara/ast.c b/libyara/ast.c
index 74b627e..69735f0 100644
--- a/libyara/ast.c
+++ b/libyara/ast.c
@@ -457,7 +457,7 @@ int new_text_string(SIZED_STRING* charstr, int flags, unsigned char** hexstr, RE
              options |= PCRE_CASELESS;
          }
          
-         re->regexp = pcre_compile((char*) *hexstr, options, &error, &erroffset, NULL); 
+         re->regexp = pcre_compile(charstr->c_string, options, &error, &erroffset, NULL); 
 
          if (re->regexp != NULL)  
          {
@@ -684,21 +684,37 @@ int new_string_identifier(int type, STRING* defined_strings, char* identifier, T
 
 void free_term(TERM* term)
 {
+    TERM_STRING* next;
+    TERM_STRING* tmp;
+    
     switch(term->type)
     {
     case TERM_TYPE_STRING:
-        break;//TODO: free next
+    
+        next = ((TERM_STRING*) term)->next;
+    
+        while (next != NULL)
+        {
+            tmp = next->next;
+            free(next);
+            next = tmp;     
+        }
+    
+        break;
     
 	case TERM_TYPE_STRING_AT:
+	
 		free_term(((TERM_STRING*)term)->offset);
 		break;
 	
 	case TERM_TYPE_STRING_IN_RANGE:
+	
         free_term(((TERM_STRING*)term)->lower_offset);
 		free_term(((TERM_STRING*)term)->upper_offset);
         break;
 
 	case TERM_TYPE_STRING_IN_SECTION_BY_NAME:
+	    
 	    free(((TERM_STRING*)term)->section_name);
 		break;
                     
diff --git a/libyara/error.c b/libyara/error.c
index 08d50c3..7e3e3d6 100644
--- a/libyara/error.c
+++ b/libyara/error.c
@@ -33,8 +33,6 @@ char error_message[500];
 
 YARAREPORT report_function = NULL;
 
-//TODO: Arreglar los mensajes de error en yara-python. No sale nada cuando se trata de un error de sintaxis de yyparse
-
 void yyerror(const char *error_message)
 {    
     if (last_result != ERROR_SUCCESS) 
diff --git a/libyara/grammar.c b/libyara/grammar.c
index dd25638..f97e409 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -183,7 +183,7 @@
 #include "sizedstr.h"
 
 #define YYERROR_VERBOSE
-#define YYDEBUG 1
+//#define YYDEBUG 1
 
 
 
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 9a2435b..3be5c9f 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -11,7 +11,7 @@
 #include "sizedstr.h"
 
 #define YYERROR_VERBOSE
-#define YYDEBUG 1
+//#define YYDEBUG 1
 
 %} 
 
diff --git a/libyara/lex.c b/libyara/lex.c
index 597d598..4399889 100644
--- a/libyara/lex.c
+++ b/libyara/lex.c
@@ -349,7 +349,7 @@ static yyconst int yy_meta[55] =
     {   0,
         1,    1,    2,    3,    1,    4,    1,    1,    3,    5,
         6,    7,    7,    7,    7,    7,    7,    7,    1,    1,
-        1,    1,    8,    8,    9,   10,   10,   11,   12,    8,
+        1,    1,    8,    8,    9,   10,   10,   11,    9,    8,
         8,    8,    8,    8,    8,    9,    9,    9,    9,    9,
         9,    9,    9,    9,    9,    9,    9,    9,    9,   10,
         9,    9,    1,    1
@@ -357,29 +357,29 @@ static yyconst int yy_meta[55] =
 
 static yyconst short int yy_base[211] =
     {   0,
-        0,    0,   52,   53,   54,   57,  324,  325,  325,  325,
-      303,  325,    0,  312,   51,   37,   40,  301,  300,  299,
-        0,    0,   30,  276,  276,   53,  277,   29,  273,   42,
-      270,   25,   50,   55,  275,  274,    0,    0,  325,  325,
-       73,    0,  325,  325,  300,  325,    0,  325,  300,  299,
-      305,    0,  283,  282,    0,  325,  325,  325,    0,    0,
-      266,   55,  272,    0,  262,  256,  262,  261,  255,  259,
-      255,  250,    0,   57,  260,    0,  256,  254,  262,  259,
-      246,  255,  241,  246,  253,  231,    0,  325,  325,  325,
-      325,    0,    0,  325,  325,  274,  272,  279,  325,  325,
-
-        0,    0,    0,    0,  243,  247,  235,  233,  243,    0,
-      237,  244,   89,  244,    0,  228,  224,  237,    0,  224,
-      231,  228,  233,  220,  231,  325,    0,  325,  226,  225,
-      211,  227,  215,  210,  228,  240,  242,    0,  170,  178,
-      177,    0,  165,  147,    0,    0,   95,    0,  325,    0,
-      135,  136,    0,  137,  132,  134,    0,    0,  136,  114,
-      113,  111,   86,  104,  106,    0,   80,   75,   64,   71,
+        0,    0,   52,   53,   54,   57,  315,  316,  316,  316,
+      294,  316,    0,  303,   51,   37,   40,  292,  291,  290,
+        0,    0,   30,  267,  267,   53,  268,   29,  264,   42,
+      261,   25,   50,   55,  266,  265,    0,    0,  316,  316,
+       73,    0,  316,  316,  291,  316,    0,  316,  291,  290,
+      296,    0,  274,  273,    0,  316,  316,  316,    0,    0,
+      257,   55,  263,    0,  253,  247,  253,  252,  246,  250,
+      246,  241,    0,   57,  251,    0,  247,  245,  253,  250,
+      237,  246,  232,  237,  244,  222,    0,  316,  316,  316,
+      316,    0,    0,  316,  316,  265,  263,  270,  316,  316,
+
+        0,    0,    0,    0,  234,  238,  226,  224,  234,    0,
+      228,  235,   89,  235,    0,  219,  215,  228,    0,  215,
+      222,  219,  224,  211,  222,  316,    0,  316,  217,  216,
+      202,  218,  206,  201,  219,  231,  233,    0,  201,  211,
+      214,    0,  168,  159,    0,    0,   95,    0,  316,    0,
+      150,  134,    0,  137,  129,  131,    0,    0,  135,  112,
+      111,  109,   86,  104,  106,    0,   80,   75,   64,   71,
         0,    0,    0,   80,   71,   66,    0,    0,   67,   67,
        64,   64,    0,    0,    0,   53,   52,    0,    0,    0,
-       32,    0,  325,  123,  135,  141,  147,  151,  155,  159,
+       32,    0,  316,  123,  134,  139,  145,  149,  153,  157,
 
-      169,  177,  189,  201,  213,  225,  237,  243,  245,  247
+      165,  173,  183,  194,  204,  215,  226,  231,  233,  235
     } ;
 
 static yyconst short int yy_def[211] =
@@ -409,7 +409,7 @@ static yyconst short int yy_def[211] =
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193
     } ;
 
-static yyconst short int yy_nxt[380] =
+static yyconst short int yy_nxt[371] =
     {   0,
         8,    9,   10,    9,   11,   12,   13,   14,    8,    8,
        15,   16,   17,   17,   17,   17,   17,   17,   18,   19,
@@ -425,36 +425,35 @@ static yyconst short int yy_nxt[380] =
        90,  136,  115,  137,  187,  104,  138,  164,  186,  165,
       185,  184,  166,  183,  182,  181,  180,  179,   91,  178,
       177,  176,   92,   38,   38,   38,   38,   38,   38,   38,
-       38,   38,   38,   38,   38,   42,   42,   42,   42,   42,
-       42,   42,   42,   42,   42,   42,   42,   47,   47,   47,
-       47,   49,  175,   49,   49,   49,   49,   52,  174,  173,
-       52,   59,   59,   59,   59,   60,   60,   60,   60,  172,
-       60,   86,  171,  170,  169,   86,   86,   87,  168,   87,
-      167,   87,   87,   87,   87,   87,   87,  163,   87,   88,
-       88,   88,   88,   88,   88,   88,   88,   88,   88,   88,
-
-       88,   93,  162,   93,   93,   93,  161,   93,   93,   93,
-       93,  160,   93,   94,  159,   94,   94,   94,   94,   94,
+       38,   38,   38,   38,   42,   42,   42,   42,   42,   42,
+       42,   42,   42,   42,   42,   47,   47,   47,   47,   49,
+      175,   49,   49,   49,   49,   52,  174,  173,   52,   59,
+       59,   59,   59,   60,   60,   60,   60,   86,  172,  171,
+      170,   86,   86,   87,  169,   87,  168,   87,   87,   87,
+       87,   87,   87,   88,   88,   88,   88,   88,   88,   88,
+       88,   88,   88,   88,   93,  167,   93,   93,   93,  163,
+
+       93,   93,   93,   93,   94,  162,   94,   94,   94,   94,
        94,   94,   94,   94,   94,   96,   96,   96,   96,   96,
-       96,   96,   96,   96,   96,   96,   96,   98,   98,   98,
-       98,   98,   98,   98,   98,   98,   98,   98,   98,  101,
-      101,  127,  127,  149,  149,  158,  157,  156,  155,  154,
-      153,  152,  151,  150,  148,  147,  146,  145,  144,  143,
-      142,  141,  140,  139,  135,  134,  133,  132,  131,  130,
-      129,   99,  128,   97,  126,  125,  124,  123,  122,  121,
-      120,  119,  118,  117,  116,  113,  112,  111,  110,  109,
-
-      108,  107,  106,  105,  102,  100,  100,   99,   97,   48,
-       95,   85,   84,   77,   74,   71,   66,   65,   58,   57,
-       56,   48,   46,  193,    7,  193,  193,  193,  193,  193,
+       96,   96,   96,   96,   96,   96,   98,   98,   98,   98,
+       98,   98,   98,   98,   98,   98,   98,  101,  101,  127,
+      127,  149,  149,  161,  160,  159,  158,  157,  156,  155,
+      154,  153,  152,  151,  150,  148,  147,  146,  145,  144,
+      143,  142,  141,  140,  139,  135,  134,  133,  132,  131,
+      130,  129,   99,  128,   97,  126,  125,  124,  123,  122,
+      121,  120,  119,  118,  117,  116,  113,  112,  111,  110,
+      109,  108,  107,  106,  105,  102,  100,  100,   99,   97,
+
+       48,   95,   85,   84,   77,   74,   71,   66,   65,   58,
+       57,   56,   48,   46,  193,    7,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193
+      193,  193,  193,  193,  193,  193,  193,  193,  193,  193
     } ;
 
-static yyconst short int yy_chk[380] =
+static yyconst short int yy_chk[371] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -470,33 +469,32 @@ static yyconst short int yy_chk[380] =
        41,  113,   74,  113,  180,   62,  113,  147,  179,  147,
       176,  175,  147,  174,  170,  169,  168,  167,   41,  165,
       164,  163,   41,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  195,  195,  195,  195,  195,
-      195,  195,  195,  195,  195,  195,  195,  196,  196,  196,
-      196,  197,  162,  197,  197,  197,  197,  198,  161,  160,
-      198,  199,  199,  199,  199,  200,  200,  200,  200,  159,
-      200,  201,  156,  155,  154,  201,  201,  202,  152,  202,
-      151,  202,  202,  202,  202,  202,  202,  144,  202,  203,
-      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
-
-      203,  204,  143,  204,  204,  204,  141,  204,  204,  204,
-      204,  140,  204,  205,  139,  205,  205,  205,  205,  205,
+      194,  194,  194,  194,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  196,  196,  196,  196,  197,
+      162,  197,  197,  197,  197,  198,  161,  160,  198,  199,
+      199,  199,  199,  200,  200,  200,  200,  201,  159,  156,
+      155,  201,  201,  202,  154,  202,  152,  202,  202,  202,
+      202,  202,  202,  203,  203,  203,  203,  203,  203,  203,
+      203,  203,  203,  203,  204,  151,  204,  204,  204,  144,
+
+      204,  204,  204,  204,  205,  143,  205,  205,  205,  205,
       205,  205,  205,  205,  205,  206,  206,  206,  206,  206,
-      206,  206,  206,  206,  206,  206,  206,  207,  207,  207,
-      207,  207,  207,  207,  207,  207,  207,  207,  207,  208,
-      208,  209,  209,  210,  210,  137,  136,  135,  134,  133,
-      132,  131,  130,  129,  125,  124,  123,  122,  121,  120,
-      118,  117,  116,  114,  112,  111,  109,  108,  107,  106,
-      105,   98,   97,   96,   86,   85,   84,   83,   82,   81,
-       80,   79,   78,   77,   75,   72,   71,   70,   69,   68,
-
-       67,   66,   65,   63,   61,   54,   53,   51,   50,   49,
-       45,   36,   35,   31,   29,   27,   25,   24,   20,   19,
-       18,   14,   11,    7,  193,  193,  193,  193,  193,  193,
+      206,  206,  206,  206,  206,  206,  207,  207,  207,  207,
+      207,  207,  207,  207,  207,  207,  207,  208,  208,  209,
+      209,  210,  210,  141,  140,  139,  137,  136,  135,  134,
+      133,  132,  131,  130,  129,  125,  124,  123,  122,  121,
+      120,  118,  117,  116,  114,  112,  111,  109,  108,  107,
+      106,  105,   98,   97,   96,   86,   85,   84,   83,   82,
+       81,   80,   79,   78,   77,   75,   72,   71,   70,   69,
+       68,   67,   66,   65,   63,   61,   54,   53,   51,   50,
+
+       49,   45,   36,   35,   31,   29,   27,   25,   24,   20,
+       19,   18,   14,   11,    7,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193
+      193,  193,  193,  193,  193,  193,  193,  193,  193,  193
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -536,7 +534,7 @@ unsigned short string_buf_len;
 
 #define regexp 2
 
-#line 540 "lex.c"
+#line 538 "lex.c"
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -690,7 +688,7 @@ YY_DECL
 #line 33 "lex.l"
 
 
-#line 694 "lex.c"
+#line 692 "lex.c"
 
 	if ( yy_init )
 		{
@@ -747,7 +745,7 @@ yy_match:
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			++yy_cp;
 			}
-		while ( yy_base[yy_current_state] != 325 );
+		while ( yy_base[yy_current_state] != 316 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -1090,7 +1088,7 @@ YY_RULE_SETUP
 						
 						s->length = string_buf_len;
 						
-						memcpy(s->c_string, string_buf, string_buf_len);
+						strcpy(s->c_string, string_buf);
 					
 						yylval.sized_string = s;
 												
@@ -1174,8 +1172,8 @@ YY_RULE_SETUP
 
 						s->length = string_buf_len;
 
-						memcpy(s->c_string, string_buf, string_buf_len);
-
+						strcpy(s->c_string, string_buf);
+					
 						yylval.sized_string = s;
 
 						return _REGEXP_;
@@ -1280,7 +1278,7 @@ YY_RULE_SETUP
 #line 297 "lex.l"
 ECHO;
 	YY_BREAK
-#line 1284 "lex.c"
+#line 1282 "lex.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(str):
 case YY_STATE_EOF(regexp):
diff --git a/libyara/lex.l b/libyara/lex.l
index 598106d..0e36eaa 100644
--- a/libyara/lex.l
+++ b/libyara/lex.l
@@ -91,24 +91,24 @@ hexdigit      [a-fA-F0-9]
 								line_number++;
 							}
 							
-$({letter}|{digit})*"*" {
+$({letter}|{digit}|_)*"*" {
                        		yylval.c_string = (char*) strdup(yytext);
                        		return _STRING_IDENTIFIER_WITH_WILDCARD_;      
 					 	}
 
-$({letter}|{digit})* {
+$({letter}|{digit}|_)* {
                        		yylval.c_string = (char*) strdup(yytext);
                        		return _STRING_IDENTIFIER_;      
 					 }
 				
 					
-#({letter}|{digit})* {	
+#({letter}|{digit}|_)* {	
                        		yylval.c_string = (char*) strdup(yytext);
 							yylval.c_string[0] = '$'; 					/* replace # by $*/
 		                    return _STRING_COUNT_;      
 					 }
 					
-@({letter}|{digit})* {	
+@({letter}|{digit}|_)* {	
 	                      	yylval.c_string = (char*) strdup(yytext);
 							yylval.c_string[0] = '$'; 					/* replace @ by $*/
 		                    return _STRING_OFFSET_;      
@@ -163,7 +163,7 @@ $({letter}|{digit})* {
 						
 						s->length = string_buf_len;
 						
-						memcpy(s->c_string, string_buf, string_buf_len);
+						strcpy(s->c_string, string_buf);
 					
 						yylval.sized_string = s;
 												
@@ -222,8 +222,8 @@ $({letter}|{digit})* {
 
 						s->length = string_buf_len;
 
-						memcpy(s->c_string, string_buf, string_buf_len);
-
+						strcpy(s->c_string, string_buf);
+					
 						yylval.sized_string = s;
 
 						return _REGEXP_;
diff --git a/libyara/libyara.tmproj b/libyara/libyara.tmproj
index f2f2397..84f0eda 100644
--- a/libyara/libyara.tmproj
+++ b/libyara/libyara.tmproj
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
 	<key>currentDocument</key>
-	<string>../yara.c</string>
+	<string>lex.l</string>
 	<key>documents</key>
 	<array>
 		<dict>
@@ -55,21 +55,21 @@
 					<key>filename</key>
 					<string>lex.l</string>
 					<key>lastUsed</key>
-					<date>2009-02-11T17:35:41Z</date>
+					<date>2009-02-16T16:49:41Z</date>
+					<key>selected</key>
+					<true/>
 				</dict>
 				<dict>
 					<key>filename</key>
 					<string>grammar.y</string>
 					<key>lastUsed</key>
-					<date>2009-02-11T18:36:02Z</date>
+					<date>2009-02-16T16:49:41Z</date>
 				</dict>
 				<dict>
 					<key>filename</key>
 					<string>../yara.c</string>
 					<key>lastUsed</key>
-					<date>2009-02-13T15:54:54Z</date>
-					<key>selected</key>
-					<true/>
+					<date>2009-02-16T16:49:37Z</date>
 				</dict>
 			</array>
 			<key>expanded</key>
@@ -163,7 +163,7 @@
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>38</integer>
+			<integer>68</integer>
 		</dict>
 		<key>ast.c</key>
 		<dict>
@@ -338,14 +338,14 @@
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>9</integer>
+				<integer>20</integer>
 				<key>line</key>
-				<integer>281</integer>
+				<integer>110</integer>
 			</dict>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>88</integer>
+			<integer>134</integer>
 		</dict>
 		<key>pefile.c</key>
 		<dict>
@@ -444,6 +444,8 @@
 		<string>error.h</string>
 		<string>pefile.c</string>
 		<string>../yara.c</string>
+		<string>grammar.y</string>
+		<string>lex.l</string>
 		<string>scan.c</string>
 	</array>
 	<key>showFileHierarchyDrawer</key>
diff --git a/yara-python/setup.py b/yara-python/setup.py
index b917bd4..e25bbac 100644
--- a/yara-python/setup.py
+++ b/yara-python/setup.py
@@ -2,7 +2,7 @@ from distutils.core import setup, Extension
 
                            
 setup(name = "yara-python",
-        version = "1.2",
+        version = "1.2.1",
         author = "Victor M. Alvarez",
         author_email = "plusvic at gmail.com",
         url = 'http://yara.googlecode.com',
diff --git a/yara-python/setupwin.py b/yara-python/setupwin.py
index 588af15..999bbe8 100644
--- a/yara-python/setupwin.py
+++ b/yara-python/setupwin.py
@@ -2,7 +2,7 @@ from distutils.core import setup, Extension
 
                            
 setup(name = "yara-python",
-        version = "1.2",
+        version = "1.2.1",
         author = "Victor M. Alvarez",
         author_email = "plusvic at gmail.com",
         ext_modules = [ Extension(

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