... | ... |
@@ -688,10 +688,6 @@ int yr_execute_code( |
688 | 688 |
string = UINT64_TO_PTR(YR_STRING*, r2); |
689 | 689 |
#if REAL_YARA |
690 | 690 |
match = string->matches[tidx].head; |
691 |
-#else |
|
692 |
- //TBD: find clamav matches |
|
693 |
- match = NULL; //TEMP |
|
694 |
-#endif |
|
695 | 691 |
i = 1; |
696 | 692 |
found = FALSE; |
697 | 693 |
|
... | ... |
@@ -706,6 +702,20 @@ int yr_execute_code( |
706 | 706 |
i++; |
707 | 707 |
match = match->next; |
708 | 708 |
} |
709 |
+#else |
|
710 |
+ i = r1 - 1; |
|
711 |
+ found = FALSE; |
|
712 |
+ ls_matches = acdata->lsig_matches[aclsig->id]; |
|
713 |
+ if (ls_matches != NULL && i >= 0) { |
|
714 |
+ ss_matches = ls_matches->matches[string->subsig_id]; |
|
715 |
+ if (ss_matches != NULL) { |
|
716 |
+ if (i < ss_matches->next) { |
|
717 |
+ push(ss_matches->offsets[i]); |
|
718 |
+ found = TRUE; |
|
719 |
+ } |
|
720 |
+ } |
|
721 |
+ } |
|
722 |
+#endif |
|
709 | 723 |
|
710 | 724 |
if (!found) |
711 | 725 |
push(UNDEFINED); |
... | ... |
@@ -664,8 +664,8 @@ static const yytype_uint16 yyrline[] = |
664 | 664 |
1284, 1311, 1338, 1342, 1350, 1351, 1356, 1378, 1390, 1406, |
665 | 665 |
1405, 1411, 1423, 1424, 1429, 1434, 1443, 1444, 1451, 1462, |
666 | 666 |
1466, 1475, 1490, 1501, 1512, 1523, 1534, 1545, 1556, 1565, |
667 |
- 1590, 1603, 1616, 1636, 1671, 1680, 1689, 1698, 1707, 1716, |
|
668 |
- 1725, 1734, 1743, 1751, 1760, 1769 |
|
667 |
+ 1590, 1603, 1618, 1640, 1675, 1684, 1693, 1702, 1711, 1720, |
|
668 |
+ 1729, 1738, 1747, 1755, 1764, 1773 |
|
669 | 669 |
}; |
670 | 670 |
#endif |
671 | 671 |
|
... | ... |
@@ -2751,8 +2751,6 @@ yyreduce: |
2751 | 2751 |
{ |
2752 | 2752 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "at"); |
2753 | 2753 |
|
2754 |
- compiler->current_rule_clflags |= RULE_OFFSETS; |
|
2755 |
- |
|
2756 | 2754 |
compiler->last_result = yr_parser_reduce_string_identifier( |
2757 | 2755 |
yyscanner, |
2758 | 2756 |
(yyvsp[(1) - (3)].c_string), |
... | ... |
@@ -2762,6 +2760,8 @@ yyreduce: |
2762 | 2762 |
|
2763 | 2763 |
ERROR_IF(compiler->last_result != ERROR_SUCCESS); |
2764 | 2764 |
|
2765 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
2766 |
+ |
|
2765 | 2767 |
(yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN; |
2766 | 2768 |
} |
2767 | 2769 |
break; |
... | ... |
@@ -2771,8 +2771,6 @@ yyreduce: |
2771 | 2771 |
/* Line 1806 of yacc.c */ |
2772 | 2772 |
#line 960 "yara_grammar.y" |
2773 | 2773 |
{ |
2774 |
- compiler->current_rule_clflags |= RULE_OFFSETS; |
|
2775 |
- |
|
2776 | 2774 |
compiler->last_result = yr_parser_reduce_string_identifier( |
2777 | 2775 |
yyscanner, |
2778 | 2776 |
(yyvsp[(1) - (3)].c_string), |
... | ... |
@@ -2782,6 +2780,8 @@ yyreduce: |
2782 | 2782 |
|
2783 | 2783 |
ERROR_IF(compiler->last_result!= ERROR_SUCCESS); |
2784 | 2784 |
|
2785 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
2786 |
+ |
|
2785 | 2787 |
(yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN; |
2786 | 2788 |
} |
2787 | 2789 |
break; |
... | ... |
@@ -3600,6 +3600,8 @@ yyreduce: |
3600 | 3600 |
|
3601 | 3601 |
ERROR_IF(compiler->last_result != ERROR_SUCCESS); |
3602 | 3602 |
|
3603 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
3604 |
+ |
|
3603 | 3605 |
(yyval.expression_type) = EXPRESSION_TYPE_INTEGER; |
3604 | 3606 |
} |
3605 | 3607 |
break; |
... | ... |
@@ -3607,7 +3609,7 @@ yyreduce: |
3607 | 3607 |
case 102: |
3608 | 3608 |
|
3609 | 3609 |
/* Line 1806 of yacc.c */ |
3610 |
-#line 1617 "yara_grammar.y" |
|
3610 |
+#line 1619 "yara_grammar.y" |
|
3611 | 3611 |
{ |
3612 | 3612 |
compiler->last_result = yr_parser_emit_with_arg( |
3613 | 3613 |
yyscanner, |
... | ... |
@@ -3625,6 +3627,8 @@ yyreduce: |
3625 | 3625 |
|
3626 | 3626 |
ERROR_IF(compiler->last_result != ERROR_SUCCESS); |
3627 | 3627 |
|
3628 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
3629 |
+ |
|
3628 | 3630 |
(yyval.expression_type) = EXPRESSION_TYPE_INTEGER; |
3629 | 3631 |
} |
3630 | 3632 |
break; |
... | ... |
@@ -3632,7 +3636,7 @@ yyreduce: |
3632 | 3632 |
case 103: |
3633 | 3633 |
|
3634 | 3634 |
/* Line 1806 of yacc.c */ |
3635 |
-#line 1637 "yara_grammar.y" |
|
3635 |
+#line 1641 "yara_grammar.y" |
|
3636 | 3636 |
{ |
3637 | 3637 |
if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -1) // loop identifier |
3638 | 3638 |
{ |
... | ... |
@@ -3672,7 +3676,7 @@ yyreduce: |
3672 | 3672 |
case 104: |
3673 | 3673 |
|
3674 | 3674 |
/* Line 1806 of yacc.c */ |
3675 |
-#line 1672 "yara_grammar.y" |
|
3675 |
+#line 1676 "yara_grammar.y" |
|
3676 | 3676 |
{ |
3677 | 3677 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+"); |
3678 | 3678 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+"); |
... | ... |
@@ -3686,7 +3690,7 @@ yyreduce: |
3686 | 3686 |
case 105: |
3687 | 3687 |
|
3688 | 3688 |
/* Line 1806 of yacc.c */ |
3689 |
-#line 1681 "yara_grammar.y" |
|
3689 |
+#line 1685 "yara_grammar.y" |
|
3690 | 3690 |
{ |
3691 | 3691 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-"); |
3692 | 3692 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-"); |
... | ... |
@@ -3700,7 +3704,7 @@ yyreduce: |
3700 | 3700 |
case 106: |
3701 | 3701 |
|
3702 | 3702 |
/* Line 1806 of yacc.c */ |
3703 |
-#line 1690 "yara_grammar.y" |
|
3703 |
+#line 1694 "yara_grammar.y" |
|
3704 | 3704 |
{ |
3705 | 3705 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*"); |
3706 | 3706 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*"); |
... | ... |
@@ -3714,7 +3718,7 @@ yyreduce: |
3714 | 3714 |
case 107: |
3715 | 3715 |
|
3716 | 3716 |
/* Line 1806 of yacc.c */ |
3717 |
-#line 1699 "yara_grammar.y" |
|
3717 |
+#line 1703 "yara_grammar.y" |
|
3718 | 3718 |
{ |
3719 | 3719 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\"); |
3720 | 3720 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\"); |
... | ... |
@@ -3728,7 +3732,7 @@ yyreduce: |
3728 | 3728 |
case 108: |
3729 | 3729 |
|
3730 | 3730 |
/* Line 1806 of yacc.c */ |
3731 |
-#line 1708 "yara_grammar.y" |
|
3731 |
+#line 1712 "yara_grammar.y" |
|
3732 | 3732 |
{ |
3733 | 3733 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%"); |
3734 | 3734 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%"); |
... | ... |
@@ -3742,7 +3746,7 @@ yyreduce: |
3742 | 3742 |
case 109: |
3743 | 3743 |
|
3744 | 3744 |
/* Line 1806 of yacc.c */ |
3745 |
-#line 1717 "yara_grammar.y" |
|
3745 |
+#line 1721 "yara_grammar.y" |
|
3746 | 3746 |
{ |
3747 | 3747 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^"); |
3748 | 3748 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^"); |
... | ... |
@@ -3756,7 +3760,7 @@ yyreduce: |
3756 | 3756 |
case 110: |
3757 | 3757 |
|
3758 | 3758 |
/* Line 1806 of yacc.c */ |
3759 |
-#line 1726 "yara_grammar.y" |
|
3759 |
+#line 1730 "yara_grammar.y" |
|
3760 | 3760 |
{ |
3761 | 3761 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^"); |
3762 | 3762 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^"); |
... | ... |
@@ -3770,7 +3774,7 @@ yyreduce: |
3770 | 3770 |
case 111: |
3771 | 3771 |
|
3772 | 3772 |
/* Line 1806 of yacc.c */ |
3773 |
-#line 1735 "yara_grammar.y" |
|
3773 |
+#line 1739 "yara_grammar.y" |
|
3774 | 3774 |
{ |
3775 | 3775 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|"); |
3776 | 3776 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|"); |
... | ... |
@@ -3784,7 +3788,7 @@ yyreduce: |
3784 | 3784 |
case 112: |
3785 | 3785 |
|
3786 | 3786 |
/* Line 1806 of yacc.c */ |
3787 |
-#line 1744 "yara_grammar.y" |
|
3787 |
+#line 1748 "yara_grammar.y" |
|
3788 | 3788 |
{ |
3789 | 3789 |
CHECK_TYPE((yyvsp[(2) - (2)].expression_type), EXPRESSION_TYPE_INTEGER, "~"); |
3790 | 3790 |
|
... | ... |
@@ -3797,7 +3801,7 @@ yyreduce: |
3797 | 3797 |
case 113: |
3798 | 3798 |
|
3799 | 3799 |
/* Line 1806 of yacc.c */ |
3800 |
-#line 1752 "yara_grammar.y" |
|
3800 |
+#line 1756 "yara_grammar.y" |
|
3801 | 3801 |
{ |
3802 | 3802 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<"); |
3803 | 3803 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<"); |
... | ... |
@@ -3811,7 +3815,7 @@ yyreduce: |
3811 | 3811 |
case 114: |
3812 | 3812 |
|
3813 | 3813 |
/* Line 1806 of yacc.c */ |
3814 |
-#line 1761 "yara_grammar.y" |
|
3814 |
+#line 1765 "yara_grammar.y" |
|
3815 | 3815 |
{ |
3816 | 3816 |
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>"); |
3817 | 3817 |
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>"); |
... | ... |
@@ -3825,7 +3829,7 @@ yyreduce: |
3825 | 3825 |
case 115: |
3826 | 3826 |
|
3827 | 3827 |
/* Line 1806 of yacc.c */ |
3828 |
-#line 1770 "yara_grammar.y" |
|
3828 |
+#line 1774 "yara_grammar.y" |
|
3829 | 3829 |
{ |
3830 | 3830 |
(yyval.expression_type) = (yyvsp[(1) - (1)].expression_type); |
3831 | 3831 |
} |
... | ... |
@@ -3834,7 +3838,7 @@ yyreduce: |
3834 | 3834 |
|
3835 | 3835 |
|
3836 | 3836 |
/* Line 1806 of yacc.c */ |
3837 |
-#line 3838 "yara_grammar.c" |
|
3837 |
+#line 3842 "yara_grammar.c" |
|
3838 | 3838 |
default: break; |
3839 | 3839 |
} |
3840 | 3840 |
/* User semantic actions sometimes alter yychar, and that requires |
... | ... |
@@ -4065,6 +4069,6 @@ yyreturn: |
4065 | 4065 |
|
4066 | 4066 |
|
4067 | 4067 |
/* Line 2067 of yacc.c */ |
4068 |
-#line 1775 "yara_grammar.y" |
|
4068 |
+#line 1779 "yara_grammar.y" |
|
4069 | 4069 |
|
4070 | 4070 |
|
... | ... |
@@ -943,8 +943,6 @@ expression |
943 | 943 |
{ |
944 | 944 |
CHECK_TYPE($3, EXPRESSION_TYPE_INTEGER, "at"); |
945 | 945 |
|
946 |
- compiler->current_rule_clflags |= RULE_OFFSETS; |
|
947 |
- |
|
948 | 946 |
compiler->last_result = yr_parser_reduce_string_identifier( |
949 | 947 |
yyscanner, |
950 | 948 |
$1, |
... | ... |
@@ -954,12 +952,12 @@ expression |
954 | 954 |
|
955 | 955 |
ERROR_IF(compiler->last_result != ERROR_SUCCESS); |
956 | 956 |
|
957 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
958 |
+ |
|
957 | 959 |
$$ = EXPRESSION_TYPE_BOOLEAN; |
958 | 960 |
} |
959 | 961 |
| _STRING_IDENTIFIER_ _IN_ range |
960 | 962 |
{ |
961 |
- compiler->current_rule_clflags |= RULE_OFFSETS; |
|
962 |
- |
|
963 | 963 |
compiler->last_result = yr_parser_reduce_string_identifier( |
964 | 964 |
yyscanner, |
965 | 965 |
$1, |
... | ... |
@@ -969,6 +967,8 @@ expression |
969 | 969 |
|
970 | 970 |
ERROR_IF(compiler->last_result!= ERROR_SUCCESS); |
971 | 971 |
|
972 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
973 |
+ |
|
972 | 974 |
$$ = EXPRESSION_TYPE_BOOLEAN; |
973 | 975 |
} |
974 | 976 |
| _FOR_ for_expression _IDENTIFIER_ _IN_ |
... | ... |
@@ -1611,6 +1611,8 @@ primary_expression |
1611 | 1611 |
|
1612 | 1612 |
ERROR_IF(compiler->last_result != ERROR_SUCCESS); |
1613 | 1613 |
|
1614 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
1615 |
+ |
|
1614 | 1616 |
$$ = EXPRESSION_TYPE_INTEGER; |
1615 | 1617 |
} |
1616 | 1618 |
| _STRING_OFFSET_ |
... | ... |
@@ -1631,6 +1633,8 @@ primary_expression |
1631 | 1631 |
|
1632 | 1632 |
ERROR_IF(compiler->last_result != ERROR_SUCCESS); |
1633 | 1633 |
|
1634 |
+ compiler->current_rule_clflags |= RULE_OFFSETS; |
|
1635 |
+ |
|
1634 | 1636 |
$$ = EXPRESSION_TYPE_INTEGER; |
1635 | 1637 |
} |
1636 | 1638 |
| identifier |