summaryrefslogtreecommitdiff
path: root/archival/bunzip2.c
diff options
context:
space:
mode:
authorRob Landley2006-06-13 14:54:42 +0000
committerRob Landley2006-06-13 14:54:42 +0000
commit9a202c9daaac25296129d1b2d63fedd28efe4a0d (patch)
tree906c371755ccc1abb19955b43cf91f318bf2c891 /archival/bunzip2.c
parent1dea55d577641540bfc85f1d969667d89539ef6d (diff)
downloadbusybox-9a202c9daaac25296129d1b2d63fedd28efe4a0d.zip
busybox-9a202c9daaac25296129d1b2d63fedd28efe4a0d.tar.gz
Patch from Denis Vlasenko: unlzma was make files with mode 777. Tweak
everything to do stat() and use xopen3().
Diffstat (limited to 'archival/bunzip2.c')
-rw-r--r--archival/bunzip2.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/archival/bunzip2.c b/archival/bunzip2.c
index 1b074c4..09364b4 100644
--- a/archival/bunzip2.c
+++ b/archival/bunzip2.c
@@ -41,16 +41,21 @@ int bunzip2_main(int argc, char **argv)
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
- bb_error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
+ bb_error_msg_and_die("Compressed data not read from terminal. Use -f to force it.");
}
if (filename) {
+ struct stat stat_buf;
char *extension=filename+strlen(filename)-4;
if (strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("Invalid extension");
}
+ /* TODO: xstat */
+ if (stat(filename, &stat_buf) < 0) {
+ bb_error_msg_and_die("Couldn't stat file %s", filename);
+ }
*extension=0;
- dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
+ dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if(filename) {