bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30794: Cannot produce backslash through hexadecimal - sed (GNU sed)


From: 0xddaa
Subject: bug#30794: Cannot produce backslash through hexadecimal - sed (GNU sed) 4.2.2
Date: Tue, 13 Mar 2018 18:02:05 +0800

Hi,

I use sed to modify the field of size in file header for some binaries, and
I found it will failed when the file size included *\x5c* (backslash) after
converted into hexadecimal.

There is the Proof-of-Concept:

# echo z | sed 's/z/\x5c/' # \x5c == '\'
\ # success
# echo z | sed 's/z/\x5c\x61/'
a # backslash is gone

According the manual, *\xxx* should produce an ascii character. sed should
not treat *\x5c* as an escape symbol.

I also try the replacement with '&' and it's work fine:

# echo z | sed 's/z/\x26\x61/' # \x26 == '&'
&a // replace to &
# echo z | sed 's/z/&\x61/'
za  // execute & feature

I try to fix the problem and I hope it will be useful. Sorry for my bad
English.
https://github.com/0xddaa/sed/commit/723fa224c771ecd16913aea8117aa917877bbd38

Sincerely,
ddaa


reply via email to

[Prev in Thread] Current Thread [Next in Thread]