Skip to content

Commit

Permalink
Handle yr+ command errors properly (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainpelissier authored Aug 26, 2024
1 parent bd8fb40 commit 17ef579
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core_r2yara.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,20 +473,24 @@ static void cmd_yara_add_current(R2Yara *r2yara) {

if (yr_compiler_create (&compiler) != ERROR_SUCCESS) {
logerr (compiler, NULL);
goto err_exit;
}
if (yr_compiler_add_string (compiler, r_strbuf_tostring(get_current_rule(r2yara)), NULL) > 0) {
logerr (compiler, NULL);
goto err_exit;
}

if (yr_compiler_get_rules (compiler, &yr_rules) != ERROR_SUCCESS) {
logerr (compiler, NULL);
goto err_exit;
}

r_list_append (r2yara->rules_list, yr_rules);
R_LOG_INFO ("Rule successfully added");

err_exit:
if (compiler != NULL) {
R2YR_COMPILER_DESTROY (compiler);
}
R_LOG_INFO ("Rule successfully added");
}

static char *yarastring(const char *s) {
Expand Down

0 comments on commit 17ef579

Please sign in to comment.