diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-10-05 02:44:34 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-10-05 02:44:34 +0200 |
commit | cd738711782d5860eeab4e7cefdd1f72dfb83810 (patch) | |
tree | 54677a6bd0215a0979b5c6512b805543550624b7 | |
parent | b434ce70696879aad066fff67253e44e5f5b238e (diff) | |
download | busybox-w32-cd738711782d5860eeab4e7cefdd1f72dfb83810.tar.gz busybox-w32-cd738711782d5860eeab4e7cefdd1f72dfb83810.tar.bz2 busybox-w32-cd738711782d5860eeab4e7cefdd1f72dfb83810.zip |
sed: fix "sed CMD -i nonexistent_file". Closes 7484
function old new delta
sed_main 643 676 +33
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/sed.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c index e1b8352fd..2c64ad500 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -1522,12 +1522,16 @@ int sed_main(int argc UNUSED_PARAM, char **argv) | |||
1522 | 1522 | ||
1523 | /* -i: process each FILE separately: */ | 1523 | /* -i: process each FILE separately: */ |
1524 | 1524 | ||
1525 | if (stat(*argv, &statbuf) != 0) { | ||
1526 | bb_simple_perror_msg(*argv); | ||
1527 | G.exitcode = EXIT_FAILURE; | ||
1528 | G.current_input_file++; | ||
1529 | continue; | ||
1530 | } | ||
1525 | G.outname = xasprintf("%sXXXXXX", *argv); | 1531 | G.outname = xasprintf("%sXXXXXX", *argv); |
1526 | nonstdoutfd = xmkstemp(G.outname); | 1532 | nonstdoutfd = xmkstemp(G.outname); |
1527 | G.nonstdout = xfdopen_for_write(nonstdoutfd); | 1533 | G.nonstdout = xfdopen_for_write(nonstdoutfd); |
1528 | |||
1529 | /* Set permissions/owner of output file */ | 1534 | /* Set permissions/owner of output file */ |
1530 | stat(*argv, &statbuf); | ||
1531 | /* chmod'ing AFTER chown would preserve suid/sgid bits, | 1535 | /* chmod'ing AFTER chown would preserve suid/sgid bits, |
1532 | * but GNU sed 4.2.1 does not preserve them either */ | 1536 | * but GNU sed 4.2.1 does not preserve them either */ |
1533 | fchmod(nonstdoutfd, statbuf.st_mode); | 1537 | fchmod(nonstdoutfd, statbuf.st_mode); |