Fix unescaping of \\ esc seq (#4402)

This commit is contained in:
Khairul Azhar Kasmiran 2024-03-31 11:48:15 +08:00 committed by GitHub
parent 6c05989f19
commit 754538fd8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 3 deletions

View file

@ -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;

View file

@ -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=<<EOF
wz {} \" \#
wz {} \" \\\" \\ \\\\ \n \\n \# \\\# \$ \\$
px~:1.. @!32
izzj
EOF
EXPECT=<<EOF
[{"vaddr":0,"paddr":0,"ordinal":0,"size":7,"length":6,"section":"","type":"ascii","string":"{} \" #"}]
0x00000000 7b7d 2022 205c 2220 5c20 5c5c 200a 205c {} " \" \ \\ . \
0x00000010 6e20 2320 5c23 2024 205c 2400 0000 0000 n # \# $ \$.....
[{"vaddr":0,"paddr":0,"ordinal":0,"size":28,"length":27,"section":"","type":"ascii","string":"{} \" \\\" \\ \\\\ \n \\n # \\# $ \\$"}]
EOF
RUN

View file

@ -447,6 +447,28 @@ EXPECT=<<EOF
EOF
RUN
NAME=wz macro + \\ esc seq
FILE==
CMDS=<<EOF
b 16
$addr=$0
$new_addr=%v \`$addr\`+16
(wz16 str; wz ${str} @ `$addr`; px~:1 @ `$addr`; $addr=$`$new_addr`)
.(wz16 \\)
.(wz16 \\\\)
.(wz16 \\a)
.(wz16 "a \\ b")
.(wz16 a\\)
EOF
EXPECT=<<EOF
0x00000000 5c00 0000 0000 0000 0000 0000 0000 0000 \...............
0x00000010 5c5c 0000 0000 0000 0000 0000 0000 0000 \\..............
0x00000020 5c61 0000 0000 0000 0000 0000 0000 0000 \a..............
0x00000030 6120 5c20 6200 0000 0000 0000 0000 0000 a \ b...........
0x00000040 615c 0000 0000 0000 0000 0000 0000 0000 a\..............
EOF
RUN
NAME=Automatically reanalyze function control flow after a write
FILE==
ARGS=-a x86 -b 64 -e analysis.detectwrites=true