aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Foley <bpfoley@google.com>2019-01-02 13:09:45 -0800
committerDenys Vlasenko <vda.linux@googlemail.com>2019-01-21 13:22:31 +0100
commitb7928e18b14a2bc2aa27f82b80803fdff68c328a (patch)
tree85bb9458e9e48a09089bf4470e988e3ac2dad3d2
parent1c42c18e9601ee1416d61663f5a91874954c524d (diff)
downloadbusybox-w32-b7928e18b14a2bc2aa27f82b80803fdff68c328a.tar.gz
busybox-w32-b7928e18b14a2bc2aa27f82b80803fdff68c328a.tar.bz2
busybox-w32-b7928e18b14a2bc2aa27f82b80803fdff68c328a.zip
sed: Fix backslash parsing for 'w' command arg
If there's any whitespace between w and the filename, parse_file_cmd writes to the wrong offset when trying to fix up backslashes. This can be seen in the asan build with busybox sed -e 'w 0\\' Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/sed.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 1054c1302..cddb0c732 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -387,7 +387,7 @@ static int parse_file_cmd(/*sed_cmd_t *sed_cmd,*/ const char *filecmdstr, char *
387 bb_error_msg_and_die("empty filename"); 387 bb_error_msg_and_die("empty filename");
388 *retval = xstrndup(filecmdstr+start, idx-start+hack+1); 388 *retval = xstrndup(filecmdstr+start, idx-start+hack+1);
389 if (hack) 389 if (hack)
390 (*retval)[idx] = '\\'; 390 (*retval)[idx-start] = '\\';
391 391
392 return idx; 392 return idx;
393} 393}