Skip to content

Commit 9533d6a

Browse files
committed
Fix string escaping issues in rule generation
1 parent 4262773 commit 9533d6a

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/core_r2yara.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,13 @@ static void cmd_yara_add_current(R2Yara *r2yara) {
776776
}
777777

778778
static char *yarastring(const char *s) {
779-
RStrBuf *sb = r_strbuf_new ("\"");
780-
char *a = strdup (s);
781-
r_str_trim (a);
782-
a = r_str_replace_all (a, "\n", "\\n");
783-
r_strbuf_append (sb, a);
784-
r_strbuf_append (sb, "\"");
779+
char *a = r_str_trim_dup (s);
780+
r_str_unescape (a);
781+
char *escaped = r_str_escape_raw ((const ut8 *)a, strlen (a));
785782
free (a);
786-
return r_strbuf_drain (sb);
787-
;
783+
char *res = r_str_newf ("\"%s\"", escaped);
784+
free (escaped);
785+
return res;
788786
}
789787

790788
static int cmd_yara_gen(R2Yara *r2yara, const char *input) {

0 commit comments

Comments
 (0)