aboutsummaryrefslogtreecommitdiff
path: root/archival/unlzma.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/unlzma.c')
-rw-r--r--archival/unlzma.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/archival/unlzma.c b/archival/unlzma.c
index dc85cb25e..404da0acd 100644
--- a/archival/unlzma.c
+++ b/archival/unlzma.c
@@ -41,13 +41,18 @@ int unlzma_main(int argc, char **argv)
41 filename = 0; 41 filename = 0;
42 42
43 if (filename) { 43 if (filename) {
44 struct stat stat_buf;
44 char *extension = filename + strlen(filename) - 5; 45 char *extension = filename + strlen(filename) - 5;
45 46
46 if (strcmp(extension, ".lzma") != 0) { 47 if (strcmp(extension, ".lzma") != 0) {
47 bb_error_msg_and_die("Invalid extension"); 48 bb_error_msg_and_die("Invalid extension");
48 } 49 }
50 /* TODO: xstat? */
51 if (stat(filename, &stat_buf) < 0) {
52 bb_error_msg_and_die("Couldn't stat file %s", filename);
53 }
49 *extension = 0; 54 *extension = 0;
50 dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT); 55 dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
51 } else 56 } else
52 dst_fd = STDOUT_FILENO; 57 dst_fd = STDOUT_FILENO;
53 status = unlzma(src_fd, dst_fd); 58 status = unlzma(src_fd, dst_fd);