aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-09-03 14:04:33 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-09-03 14:04:33 +0000
commitafa7ad2c499937777aeea52414006d5db63c172a (patch)
treed12f6ab92f2435ac599eb1f45b7bfeb8d7aafc1f
parent45cd27f3ff7684827fe0e12545e6c85db050ead8 (diff)
downloadbusybox-w32-afa7ad2c499937777aeea52414006d5db63c172a.tar.gz
busybox-w32-afa7ad2c499937777aeea52414006d5db63c172a.tar.bz2
busybox-w32-afa7ad2c499937777aeea52414006d5db63c172a.zip
tar: revert older fix (non-portable), added new one.
testsuite tar-extracts-all-subdirs now passes. git-svn-id: svn://busybox.net/trunk/busybox@16041 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--archival/libunarchive/filter_accept_reject_list.c4
-rw-r--r--archival/libunarchive/find_list_entry.c40
-rw-r--r--archival/tar.c6
-rw-r--r--include/unarchive.h1
4 files changed, 44 insertions, 7 deletions
diff --git a/archival/libunarchive/filter_accept_reject_list.c b/archival/libunarchive/filter_accept_reject_list.c
index be56a446f..a3a938c62 100644
--- a/archival/libunarchive/filter_accept_reject_list.c
+++ b/archival/libunarchive/filter_accept_reject_list.c
@@ -14,14 +14,14 @@
14char filter_accept_reject_list(archive_handle_t *archive_handle) 14char filter_accept_reject_list(archive_handle_t *archive_handle)
15{ 15{
16 const char *key = archive_handle->file_header->name; 16 const char *key = archive_handle->file_header->name;
17 const llist_t *reject_entry = find_list_entry(archive_handle->reject, key); 17 const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
18 const llist_t *accept_entry; 18 const llist_t *accept_entry;
19 19
20 /* If the key is in a reject list fail */ 20 /* If the key is in a reject list fail */
21 if (reject_entry) { 21 if (reject_entry) {
22 return(EXIT_FAILURE); 22 return(EXIT_FAILURE);
23 } 23 }
24 accept_entry = find_list_entry(archive_handle->accept, key); 24 accept_entry = find_list_entry2(archive_handle->accept, key);
25 25
26 /* Fail if an accept list was specified and the key wasnt in there */ 26 /* Fail if an accept list was specified and the key wasnt in there */
27 if ((accept_entry == NULL) && archive_handle->accept) { 27 if ((accept_entry == NULL) && archive_handle->accept) {
diff --git a/archival/libunarchive/find_list_entry.c b/archival/libunarchive/find_list_entry.c
index 57ffec6ec..d1afc72ce 100644
--- a/archival/libunarchive/find_list_entry.c
+++ b/archival/libunarchive/find_list_entry.c
@@ -9,14 +9,46 @@
9#include <stdlib.h> 9#include <stdlib.h>
10#include "unarchive.h" 10#include "unarchive.h"
11 11
12/* Find a string in a list */ 12/* Find a string in a shell pattern list */
13const llist_t *find_list_entry(const llist_t *list, const char *filename) 13const llist_t *find_list_entry(const llist_t *list, const char *filename)
14{ 14{
15 while (list) { 15 while (list) {
16 if (fnmatch(list->data, filename, FNM_LEADING_DIR) == 0) { 16 if (fnmatch(list->data, filename, 0) == 0) {
17 return (list); 17 return list;
18 } 18 }
19 list = list->link; 19 list = list->link;
20 } 20 }
21 return(NULL); 21 return NULL;
22}
23
24/* Same, but compares only path components present in pattern
25 * (extra trailing path components in filename are assumed to match)
26 */
27const llist_t *find_list_entry2(const llist_t *list, const char *filename)
28{
29 char buf[PATH_MAX];
30 int pattern_slash_cnt;
31 const char *c;
32 char *d;
33
34 while (list) {
35 c = list->data;
36 pattern_slash_cnt = 0;
37 while (*c)
38 if (*c++ == '/') pattern_slash_cnt++;
39 c = filename;
40 d = buf;
41 /* paranoia is better that buffer overflows */
42 while (*c && d != buf + sizeof(buf)-1) {
43 if (*c == '/' && --pattern_slash_cnt < 0)
44 break;
45 *d++ = *c++;
46 }
47 *d = '\0';
48 if (fnmatch(list->data, buf, 0) == 0) {
49 return list;
50 }
51 list = list->link;
52 }
53 return NULL;
22} 54}
diff --git a/archival/tar.c b/archival/tar.c
index 160731ea9..0b5720f3b 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -545,8 +545,12 @@ static llist_t *append_file_list_to_list(llist_t *list)
545 tmp = cur; 545 tmp = cur;
546 cur = cur->link; 546 cur = cur->link;
547 free(tmp); 547 free(tmp);
548 while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) 548 while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
549 char *filename_ptr = last_char_is(line, '/');
550 if (filename_ptr > line)
551 *filename_ptr = '\0';
549 llist_add_to(&newlist, line); 552 llist_add_to(&newlist, line);
553 }
550 fclose(src_stream); 554 fclose(src_stream);
551 } 555 }
552 return newlist; 556 return newlist;
diff --git a/include/unarchive.h b/include/unarchive.h
index 1dbbc009d..653cff80f 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -98,6 +98,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned
98 98
99extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary); 99extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary);
100extern const llist_t *find_list_entry(const llist_t *list, const char *filename); 100extern const llist_t *find_list_entry(const llist_t *list, const char *filename);
101extern const llist_t *find_list_entry2(const llist_t *list, const char *filename);
101 102
102extern int uncompressStream(int src_fd, int dst_fd); 103extern int uncompressStream(int src_fd, int dst_fd);
103extern void inflate_init(unsigned int bufsize); 104extern void inflate_init(unsigned int bufsize);