mirror of
https://github.com/sheumann/hush.git
synced 2025-03-11 03:31:40 +00:00
echo: fix echo -e -n "msg\n\0"
(by "Pinedo, David" <david.pinedo AT hp.com>)
This commit is contained in:
parent
a2dcb50175
commit
dcbd350ccf
@ -108,15 +108,19 @@ int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||||
/* SUSv3 specifies that octal escapes must begin with '0'. */
|
/* SUSv3 specifies that octal escapes must begin with '0'. */
|
||||||
if ( (((unsigned char)*arg) - '1') >= 7)
|
if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
|
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
|
||||||
* of the form \0### are accepted. */
|
* of the form \0### are accepted. */
|
||||||
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
|
if (*arg == '0') {
|
||||||
arg++;
|
/* NB: don't turn "...\0" into "...\" */
|
||||||
|
if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) {
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* bb_process_escape_sequence can handle nul correctly */
|
/* bb_process_escape_sequence handles NUL correctly
|
||||||
|
* ("...\" case). */
|
||||||
c = bb_process_escape_sequence(&arg);
|
c = bb_process_escape_sequence(&arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
testsuite/echo/echo-prints-slash-zero
Normal file
1
testsuite/echo/echo-prints-slash-zero
Normal file
@ -0,0 +1 @@
|
|||||||
|
test "`busybox echo -e -n 'msg\n\0' | od -t x1 | head -n 1`" = "0000000 6d 73 67 0a 00"
|
Loading…
x
Reference in New Issue
Block a user