aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-07-18 13:22:44 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-07-18 13:22:44 +0000
commit8aef3244ae4b1f89f0b09f41261f82a2c9f1cda3 (patch)
tree45970f02ccdfabf5370c54eca2c37321c0ab6393 /libbb
parent09269b817de33b0e8aa0531a5d6ddb420549fa97 (diff)
downloadbusybox-w32-8aef3244ae4b1f89f0b09f41261f82a2c9f1cda3.tar.gz
busybox-w32-8aef3244ae4b1f89f0b09f41261f82a2c9f1cda3.tar.bz2
busybox-w32-8aef3244ae4b1f89f0b09f41261f82a2c9f1cda3.zip
Fix extract_archive so it doesnt mangle filenames, dont try and extract "./" and strip leading "./" on other files
git-svn-id: svn://busybox.net/trunk/busybox@3121 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/unarchive.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index adc5d8d6e..ca654a6ca 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -82,8 +82,11 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
82 /* strip leading '/' in filename to extract as prefix may not be dir */ 82 /* strip leading '/' in filename to extract as prefix may not be dir */
83 /* Cant use concat_path_file here as prefix might not be a directory */ 83 /* Cant use concat_path_file here as prefix might not be a directory */
84 char *path = file_entry->name; 84 char *path = file_entry->name;
85 if (*path == '/') { 85 if (strncmp("./", path, 2) == 0) {
86 path++; 86 path += 2;
87 if (strlen(path) == 0) {
88 return(NULL);
89 }
87 } 90 }
88 full_name = xmalloc(strlen(prefix) + strlen(path) + 1); 91 full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
89 strcpy(full_name, prefix); 92 strcpy(full_name, prefix);
@@ -91,7 +94,6 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
91 } else { 94 } else {
92 full_name = file_entry->name; 95 full_name = file_entry->name;
93 } 96 }
94
95 if (function & extract_to_stdout) { 97 if (function & extract_to_stdout) {
96 if (S_ISREG(file_entry->mode)) { 98 if (S_ISREG(file_entry->mode)) {
97 copy_file_chunk(src_stream, out_stream, file_entry->size); 99 copy_file_chunk(src_stream, out_stream, file_entry->size);
@@ -244,6 +246,7 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers
244 } 246 }
245 } 247 }
246 } 248 }
249
247 if (found) { 250 if (found) {
248 buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix); 251 buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
249 } else { 252 } else {