... | ... |
@@ -3516,12 +3516,14 @@ static int cli_loadyara(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
3516 | 3516 |
rc = yr_lex_parse_rules_file(fs, &compiler); |
3517 | 3517 |
if (rc > 0) { /* rc = number of errors */ |
3518 | 3518 |
/* TODO - handle the various errors? */ |
3519 |
- cli_errmsg("cli_loadyara: failed to parse rules file\n"); |
|
3519 |
+ cli_errmsg("cli_loadyara: failed to parse rules file %s, error count %i\n", dbname, rc); |
|
3520 |
+#ifdef YARA_FINISHED |
|
3520 | 3521 |
yr_hash_table_destroy(compiler.rules_table, NULL); |
3521 | 3522 |
yr_arena_destroy(compiler.sz_arena); |
3522 | 3523 |
yr_arena_destroy(compiler.code_arena); |
3523 | 3524 |
yr_arena_destroy(compiler.strings_arena); |
3524 | 3525 |
return CL_EMALFDB; |
3526 |
+#endif |
|
3525 | 3527 |
} |
3526 | 3528 |
|
3527 | 3529 |
while (!STAILQ_EMPTY(&compiler.rule_q)) { |
... | ... |
@@ -3534,7 +3536,7 @@ static int cli_loadyara(FILE *fs, struct cl_engine *engine, unsigned int *signo, |
3534 | 3534 |
/* TODO - PUA and engine->ignored */ |
3535 | 3535 |
rc = load_oneyara(rule, engine, options, &sigs); |
3536 | 3536 |
if (rc != CL_SUCCESS) { |
3537 |
- cli_warnmsg("cli_loadyara: problem parsing yara rule %s\n", rule->id); |
|
3537 |
+ cli_warnmsg("cli_loadyara: problem parsing yara file %s, yara rule %s\n", dbname, rule->id); |
|
3538 | 3538 |
#ifdef YARA_FINISHED |
3539 | 3539 |
break; |
3540 | 3540 |
#endif |
... | ... |
@@ -3037,6 +3037,7 @@ void yyerror( |
3037 | 3037 |
|
3038 | 3038 |
compiler->last_result = ERROR_SUCCESS; |
3039 | 3039 |
#else |
3040 |
+ compiler->errors++; |
|
3040 | 3041 |
if (error_message != NULL) |
3041 | 3042 |
cli_errmsg("yara_lexer:yyerror() %s\n", error_message); |
3042 | 3043 |
else if (compiler->error_msg != NULL) |
... | ... |
@@ -3045,9 +3046,17 @@ void yyerror( |
3045 | 3045 |
cli_errmsg("yara_lexer:yyerror() %s\n", compiler->last_error_extra_info); |
3046 | 3046 |
else |
3047 | 3047 |
cli_errmsg("yara_lexer:yyerror() error unknown\n"); |
3048 |
+ if (compiler->last_result != ERROR_SUCCESS) |
|
3049 |
+ cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result); |
|
3050 |
+ if (compiler->last_result != ERROR_SUCCESS) |
|
3051 |
+ cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result); |
|
3052 |
+ if (compiler->error_line != 0) |
|
3053 |
+ cli_errmsg("yara_lexer:yyerror() error line %i\n", compiler->error_line); |
|
3054 |
+ |
|
3048 | 3055 |
compiler->last_error_extra_info[0] = (char) 0; |
3049 | 3056 |
compiler->error_msg = NULL; |
3050 | 3057 |
compiler->last_result = ERROR_SUCCESS; |
3058 |
+ compiler->error_line = 0; |
|
3051 | 3059 |
#endif |
3052 | 3060 |
} |
3053 | 3061 |
|
... | ... |
@@ -3110,10 +3119,6 @@ int yr_lex_parse_rules_file( |
3110 | 3110 |
yyparse(yyscanner, compiler); |
3111 | 3111 |
yara_yylex_destroy(yyscanner); |
3112 | 3112 |
|
3113 |
-#ifdef REAL_YARA |
|
3114 | 3113 |
return compiler->errors; |
3115 |
-#else |
|
3116 |
- return 0; |
|
3117 |
-#endif |
|
3118 | 3114 |
} |
3119 | 3115 |
|
... | ... |
@@ -703,6 +703,7 @@ void yyerror( |
703 | 703 |
|
704 | 704 |
compiler->last_result = ERROR_SUCCESS; |
705 | 705 |
#else |
706 |
+ compiler->errors++; |
|
706 | 707 |
if (error_message != NULL) |
707 | 708 |
cli_errmsg("yara_lexer:yyerror() %s\n", error_message); |
708 | 709 |
else if (compiler->error_msg != NULL) |
... | ... |
@@ -711,9 +712,17 @@ void yyerror( |
711 | 711 |
cli_errmsg("yara_lexer:yyerror() %s\n", compiler->last_error_extra_info); |
712 | 712 |
else |
713 | 713 |
cli_errmsg("yara_lexer:yyerror() error unknown\n"); |
714 |
+ if (compiler->last_result != ERROR_SUCCESS) |
|
715 |
+ cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result); |
|
716 |
+ if (compiler->last_result != ERROR_SUCCESS) |
|
717 |
+ cli_errmsg("yara_lexer:yyerror() last result is %i\n", compiler->last_result); |
|
718 |
+ if (compiler->error_line != 0) |
|
719 |
+ cli_errmsg("yara_lexer:yyerror() error line %i\n", compiler->error_line); |
|
720 |
+ |
|
714 | 721 |
compiler->last_error_extra_info[0] = (char) 0; |
715 | 722 |
compiler->error_msg = NULL; |
716 | 723 |
compiler->last_result = ERROR_SUCCESS; |
724 |
+ compiler->error_line = 0; |
|
717 | 725 |
#endif |
718 | 726 |
} |
719 | 727 |
|
... | ... |
@@ -776,9 +785,5 @@ int yr_lex_parse_rules_file( |
776 | 776 |
yyparse(yyscanner, compiler); |
777 | 777 |
yylex_destroy(yyscanner); |
778 | 778 |
|
779 |
-#ifdef REAL_YARA |
|
780 | 779 |
return compiler->errors; |
781 |
-#else |
|
782 |
- return 0; |
|
783 |
-#endif |
|
784 | 780 |
} |
... | ... |
@@ -199,7 +199,6 @@ int yr_parser_check_types( |
199 | 199 |
int i; |
200 | 200 |
|
201 | 201 |
char message[MAX_COMPILER_ERROR_EXTRA_INFO]; |
202 |
-#ifdef REAL_YARA |
|
203 | 202 |
|
204 | 203 |
const char* expected = function->arguments_fmt; |
205 | 204 |
const char* actual = actual_args_fmt; |
... | ... |
@@ -243,9 +242,6 @@ int yr_parser_check_types( |
243 | 243 |
} |
244 | 244 |
|
245 | 245 |
return compiler->last_result; |
246 |
-#else |
|
247 |
- return ERROR_SUCCESS; |
|
248 |
-#endif |
|
249 | 246 |
} |
250 | 247 |
|
251 | 248 |
|