summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorEric Andersen2002-09-30 20:14:57 +0000
committerEric Andersen2002-09-30 20:14:57 +0000
commitd9d47c3078e0f94d1fbd445f972a08c52e50417e (patch)
treee1fff694cdfa35b6a5bb12a56f1b1cf273d811bb /archival
parentaa1d6ccbfb189881dd5ab80607095002460502f6 (diff)
downloadbusybox-d9d47c3078e0f94d1fbd445f972a08c52e50417e.zip
busybox-d9d47c3078e0f94d1fbd445f972a08c52e50417e.tar.gz
Patch from Konstantin Isakov <ikm@pisem.net>:
In most cases, dirname returns the same argument it was given, so this code works nice, but there's one special case: when the name contains no dirname, it returns "." (stored statically in the body of itself), and we get a segfault in attempt to free() it. This patch fixes this problem.
Diffstat (limited to 'archival')
-rw-r--r--archival/libunarchive/data_extract_all.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index a80f422..39af2e3 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -16,9 +16,10 @@ extern void data_extract_all(archive_handle_t *archive_handle)
int res;
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
- char *dir = dirname(strdup(file_header->name));
- make_directory (dir, 0777, FILEUTILS_RECUR);
- }
+ char *name = strdup(file_header->name);
+ make_directory (dirname(name), 0777, FILEUTILS_RECUR);
+ free(name);
+ }
/* Create the file */
switch(file_header->mode & S_IFMT) {