aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-07-18 13:22:44 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-07-18 13:22:44 +0000
commit8d3b0497a4d8866f0cafd873f241971c2871d580 (patch)
tree45970f02ccdfabf5370c54eca2c37321c0ab6393 /libbb
parent778041f8d1063042a8aaff045d6a6ca98009b641 (diff)
downloadbusybox-8d3b0497a4d8866f0cafd873f241971c2871d580.tar.gz
Fix extract_archive so it doesnt mangle filenames, dont try and extract "./" and strip leading "./" on other files
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
/* strip leading '/' in filename to extract as prefix may not be dir */
/* Cant use concat_path_file here as prefix might not be a directory */
char *path = file_entry->name;
- if (*path == '/') {
- path++;
+ if (strncmp("./", path, 2) == 0) {
+ path += 2;
+ if (strlen(path) == 0) {
+ return(NULL);
+ }
}
full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
strcpy(full_name, prefix);
@@ -91,7 +94,6 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
} else {
full_name = file_entry->name;
}
-
if (function & extract_to_stdout) {
if (S_ISREG(file_entry->mode)) {
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
}
}
}
+
if (found) {
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
} else {