aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-03-18 01:19:23 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-03-18 01:19:23 +0000
commit96449df52d0b63203b1a93e53be7654020f701d9 (patch)
treea2fa6b71f3fbaa1e3b783a703160e810fdc71134
parentfe92a113a9af60424e14c31114d73e9b94d255db (diff)
downloadbusybox-w32-96449df52d0b63203b1a93e53be7654020f701d9.tar.gz
busybox-w32-96449df52d0b63203b1a93e53be7654020f701d9.tar.bz2
busybox-w32-96449df52d0b63203b1a93e53be7654020f701d9.zip
Fix a bug that corrupted the string followed commands that had no arguments (Closes #1304)
git-svn-id: svn://busybox.net/trunk/busybox@6749 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--editors/sed.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/editors/sed.c b/editors/sed.c
index e1242671e..7ff81da79 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -377,16 +377,13 @@ static int parse_file_cmd(sed_cmd_t *sed_cmd, const char *filecmdstr)
377 return idx + filenamelen; 377 return idx + filenamelen;
378} 378}
379 379
380 380/*
381 * Process the commands arguments
382 */
381static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr) 383static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
382{ 384{
383 /* if it was a single-letter command that takes no arguments (such as 'p'
384 * or 'd') all we need to do is increment the index past that command */
385 if (strchr("nNpPqd=", sed_cmd->cmd)) {
386 cmdstr++;
387 }
388 /* handle (s)ubstitution command */ 385 /* handle (s)ubstitution command */
389 else if (sed_cmd->cmd == 's') { 386 if (sed_cmd->cmd == 's') {
390 cmdstr += parse_subst_cmd(sed_cmd, cmdstr); 387 cmdstr += parse_subst_cmd(sed_cmd, cmdstr);
391 } 388 }
392 /* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */ 389 /* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */
@@ -401,7 +398,10 @@ static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
401 error_msg_and_die("Command only uses one address"); 398 error_msg_and_die("Command only uses one address");
402 cmdstr += parse_file_cmd(sed_cmd, cmdstr); 399 cmdstr += parse_file_cmd(sed_cmd, cmdstr);
403 } 400 }
404 else { 401 /* if it wasnt a single-letter command that takes no arguments
402 * then it must be an invalid command.
403 */
404 else if (strchr("nNpPqd=", sed_cmd->cmd) == 0) {
405 error_msg_and_die("Unsupported command %c", sed_cmd->cmd); 405 error_msg_and_die("Unsupported command %c", sed_cmd->cmd);
406 } 406 }
407 407