... | ... |
@@ -2832,7 +2832,7 @@ static char *parse_yara_hex_string(YR_STRING *string) |
2832 | 2832 |
return res; |
2833 | 2833 |
} |
2834 | 2834 |
|
2835 |
-void free_yararule(YR_RULE *rule) |
|
2835 |
+static inline void free_yararule(YR_RULE *rule) |
|
2836 | 2836 |
{ |
2837 | 2837 |
YR_STRING *string; |
2838 | 2838 |
|
... | ... |
@@ -2860,60 +2860,13 @@ struct cli_ytable { |
2860 | 2860 |
int32_t tbl_cnt; |
2861 | 2861 |
}; |
2862 | 2862 |
|
2863 |
-/* function is dumb - TODO - rewrite using hashtable */ |
|
2864 |
-int ytable_add_string(struct cli_ytable *ytable, const char *hexsig) |
|
2865 |
-{ |
|
2866 |
- struct cli_ytable_entry *new; |
|
2867 |
- struct cli_ytable_entry **newtable; |
|
2868 |
- int ret; |
|
2869 |
- |
|
2870 |
- if (!ytable || !hexsig) |
|
2871 |
- return CL_ENULLARG; |
|
2872 |
- |
|
2873 |
- new = cli_calloc(1, sizeof(struct cli_ytable_entry)); |
|
2874 |
- if (!new) { |
|
2875 |
- cli_yaramsg("ytable_add_string: out of memory for new ytable entry\n"); |
|
2876 |
- return CL_EMEM; |
|
2877 |
- } |
|
2878 |
- |
|
2879 |
- new->hexstr = cli_strdup(hexsig); |
|
2880 |
- if (!new->hexstr) { |
|
2881 |
- cli_yaramsg("ytable_add_string: out of memory for hexsig copy\n"); |
|
2882 |
- free(new); |
|
2883 |
- return CL_EMEM; |
|
2884 |
- } |
|
2885 |
- |
|
2886 |
- ytable->tbl_cnt++; |
|
2887 |
- newtable = cli_realloc(ytable->table, ytable->tbl_cnt * sizeof(struct cli_ytable_entry *)); |
|
2888 |
- if (!newtable) { |
|
2889 |
- cli_yaramsg("ytable_add_string: failed to reallocate new ytable table\n"); |
|
2890 |
- free(new->hexstr); |
|
2891 |
- free(new); |
|
2892 |
- ytable->tbl_cnt--; |
|
2893 |
- return CL_EMEM; |
|
2894 |
- } |
|
2895 |
- |
|
2896 |
- newtable[ytable->tbl_cnt-1] = new; |
|
2897 |
- ytable->table = newtable; |
|
2898 |
- |
|
2899 |
- if ((ret = ytable_add_attrib(ytable, NULL, "*", 0)) != CL_SUCCESS) { |
|
2900 |
- cli_yaramsg("ytable_add_string: failed to add default offset\n"); |
|
2901 |
- free(new->hexstr); |
|
2902 |
- free(new); |
|
2903 |
- ytable->tbl_cnt--; |
|
2904 |
- return ret; |
|
2905 |
- } |
|
2906 |
- |
|
2907 |
- return CL_SUCCESS; |
|
2908 |
-} |
|
2909 |
- |
|
2910 |
-int32_t ytable_lookup(const char *hexsig) |
|
2863 |
+static int32_t ytable_lookup(const char *hexsig) |
|
2911 | 2864 |
{ |
2912 | 2865 |
/* TODO - WRITE ME! */ |
2913 | 2866 |
return -1; |
2914 | 2867 |
} |
2915 | 2868 |
|
2916 |
-int ytable_add_attrib(struct cli_ytable *ytable, const char *hexsig, const char *value, int type) |
|
2869 |
+static int ytable_add_attrib(struct cli_ytable *ytable, const char *hexsig, const char *value, int type) |
|
2917 | 2870 |
{ |
2918 | 2871 |
int32_t lookup; |
2919 | 2872 |
char **attrib; |
... | ... |
@@ -2966,7 +2919,54 @@ int ytable_add_attrib(struct cli_ytable *ytable, const char *hexsig, const char |
2966 | 2966 |
return CL_SUCCESS; |
2967 | 2967 |
} |
2968 | 2968 |
|
2969 |
-void ytable_delete(struct cli_ytable *ytable) |
|
2969 |
+/* function is dumb - TODO - rewrite using hashtable */ |
|
2970 |
+static int ytable_add_string(struct cli_ytable *ytable, const char *hexsig) |
|
2971 |
+{ |
|
2972 |
+ struct cli_ytable_entry *new; |
|
2973 |
+ struct cli_ytable_entry **newtable; |
|
2974 |
+ int ret; |
|
2975 |
+ |
|
2976 |
+ if (!ytable || !hexsig) |
|
2977 |
+ return CL_ENULLARG; |
|
2978 |
+ |
|
2979 |
+ new = cli_calloc(1, sizeof(struct cli_ytable_entry)); |
|
2980 |
+ if (!new) { |
|
2981 |
+ cli_yaramsg("ytable_add_string: out of memory for new ytable entry\n"); |
|
2982 |
+ return CL_EMEM; |
|
2983 |
+ } |
|
2984 |
+ |
|
2985 |
+ new->hexstr = cli_strdup(hexsig); |
|
2986 |
+ if (!new->hexstr) { |
|
2987 |
+ cli_yaramsg("ytable_add_string: out of memory for hexsig copy\n"); |
|
2988 |
+ free(new); |
|
2989 |
+ return CL_EMEM; |
|
2990 |
+ } |
|
2991 |
+ |
|
2992 |
+ ytable->tbl_cnt++; |
|
2993 |
+ newtable = cli_realloc(ytable->table, ytable->tbl_cnt * sizeof(struct cli_ytable_entry *)); |
|
2994 |
+ if (!newtable) { |
|
2995 |
+ cli_yaramsg("ytable_add_string: failed to reallocate new ytable table\n"); |
|
2996 |
+ free(new->hexstr); |
|
2997 |
+ free(new); |
|
2998 |
+ ytable->tbl_cnt--; |
|
2999 |
+ return CL_EMEM; |
|
3000 |
+ } |
|
3001 |
+ |
|
3002 |
+ newtable[ytable->tbl_cnt-1] = new; |
|
3003 |
+ ytable->table = newtable; |
|
3004 |
+ |
|
3005 |
+ if ((ret = ytable_add_attrib(ytable, NULL, "*", 0)) != CL_SUCCESS) { |
|
3006 |
+ cli_yaramsg("ytable_add_string: failed to add default offset\n"); |
|
3007 |
+ free(new->hexstr); |
|
3008 |
+ free(new); |
|
3009 |
+ ytable->tbl_cnt--; |
|
3010 |
+ return ret; |
|
3011 |
+ } |
|
3012 |
+ |
|
3013 |
+ return CL_SUCCESS; |
|
3014 |
+} |
|
3015 |
+ |
|
3016 |
+static void ytable_delete(struct cli_ytable *ytable) |
|
2970 | 3017 |
{ |
2971 | 3018 |
uint32_t i; |
2972 | 3019 |
if (!ytable) |