From 754538fd8a29e42dcd59eef0e1381d3a4f0b2deb Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sun, 31 Mar 2024 11:48:15 +0800 Subject: [PATCH] Fix unescaping of `\\` esc seq (#4402) --- librz/core/cmd/cmd_api.c | 6 ++++++ test/db/cmd/cmd_i | 9 ++++++--- test/db/cmd/write | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/librz/core/cmd/cmd_api.c b/librz/core/cmd/cmd_api.c index 2295a13a40..1f07cb105f 100644 --- a/librz/core/cmd/cmd_api.c +++ b/librz/core/cmd/cmd_api.c @@ -2327,6 +2327,12 @@ static char *unescape_special_chars(const char *s, const char *special_chars) { int i, j = 0; for (i = 0; s[i]; i++) { + if (s[i] == '\\' && s[i + 1] == '\\') { + dst[j++] = '\\'; + dst[j++] = '\\'; + i++; + continue; + } if (s[i] != '\\' || !strchr(special_chars, s[i + 1])) { dst[j++] = s[i]; continue; diff --git a/test/db/cmd/cmd_i b/test/db/cmd/cmd_i index 7fe339fff6..63dba6da8b 100644 --- a/test/db/cmd/cmd_i +++ b/test/db/cmd/cmd_i @@ -5081,13 +5081,16 @@ nth paddr vaddr len size section type string EOF RUN -NAME=izzj double quote escape +NAME=izzj double quote & backslash escape FILE== CMDS=<