Don't leak an fd on fuzzy hash initialization

Since we're re-opening this file with every invocation, let's
close our sanity check fd.
This commit is contained in:
Robert Paprocki 2017-02-22 13:54:49 -08:00 committed by Felipe Zimmerle
parent 6cce8a2764
commit fd49ca7138
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -3828,6 +3828,7 @@ static int msre_op_fuzzy_hash_init(msre_rule *rule, char **error_msg)
{ {
#ifdef WITH_SSDEEP #ifdef WITH_SSDEEP
struct fuzzy_hash_param_data *param_data; struct fuzzy_hash_param_data *param_data;
FILE *fp;
char *file; char *file;
int param_len,threshold; int param_len,threshold;
@ -3876,14 +3877,15 @@ static int msre_op_fuzzy_hash_init(msre_rule *rule, char **error_msg)
} }
file = resolve_relative_path(rule->ruleset->mp, rule->filename, file); file = resolve_relative_path(rule->ruleset->mp, rule->filename, file);
if (!fopen(file, "r")) fp = fopen(file, "r");
if (!fp)
{ {
*error_msg = apr_psprintf(rule->ruleset->mp, "Not able to open file:" \ *error_msg = apr_psprintf(rule->ruleset->mp, "Not able to open file:" \
" %s.", file); " %s.", file);
return -1; return -1;
} }
fclose(fp);
param_data->file = file; param_data->file = file;
param_data->threshold = threshold; param_data->threshold = threshold;