diff options
-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); |