diff options
author | Rob Landley | 2006-06-13 14:54:42 +0000 |
---|---|---|
committer | Rob Landley | 2006-06-13 14:54:42 +0000 |
commit | 9a202c9daaac25296129d1b2d63fedd28efe4a0d (patch) | |
tree | 906c371755ccc1abb19955b43cf91f318bf2c891 /archival/unlzma.c | |
parent | 1dea55d577641540bfc85f1d969667d89539ef6d (diff) | |
download | busybox-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/unlzma.c')
-rw-r--r-- | archival/unlzma.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/archival/unlzma.c b/archival/unlzma.c index dc85cb2..404da0a 100644 --- a/archival/unlzma.c +++ b/archival/unlzma.c @@ -41,13 +41,18 @@ int unlzma_main(int argc, char **argv) filename = 0; if (filename) { + struct stat stat_buf; char *extension = filename + strlen(filename) - 5; if (strcmp(extension, ".lzma") != 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 = unlzma(src_fd, dst_fd); |