summaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/Makefile.in1
-rw-r--r--archival/libunarchive/filter_accept_list.c19
-rw-r--r--archival/libunarchive/filter_accept_reject_list.c21
-rw-r--r--archival/libunarchive/get_header_tar.c7
4 files changed, 19 insertions, 29 deletions
diff --git a/archival/libunarchive/Makefile.in b/archival/libunarchive/Makefile.in
index e2ac546..e559cb4 100644
--- a/archival/libunarchive/Makefile.in
+++ b/archival/libunarchive/Makefile.in
@@ -48,6 +48,7 @@ LIBUNARCHIVE-y:= \
init_handle.o \
seek_sub_file.o \
unpack_ar_archive.o \
+ find_list_entry.o
LIBUNARCHIVE-$(CONFIG_DPKG) +=
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) +=
diff --git a/archival/libunarchive/filter_accept_list.c b/archival/libunarchive/filter_accept_list.c
index 9f92e64..2b023ec 100644
--- a/archival/libunarchive/filter_accept_list.c
+++ b/archival/libunarchive/filter_accept_list.c
@@ -1,24 +1,15 @@
#include <fnmatch.h>
#include <stdlib.h>
#include "unarchive.h"
+
/*
* Accept names that are in the accept list
*/
extern char filter_accept_list(const llist_t *accept_list, const llist_t *reject_list, const char *key)
{
- llist_t *accept_old;
-
- while (accept_list) {
- if (fnmatch(accept_list->data, key, 0) == 0) {
- /* Remove entry from list */
- accept_old->link = accept_list->link;
- free(accept_list->data);
- free(accept_list);
- accept_list = accept_old;
- return(EXIT_SUCCESS);
- }
- accept_old = accept_list;
- accept_list = accept_list->link;
+ if (find_list_entry(accept_list, key)) {
+ return(EXIT_SUCCESS);
+ } else {
+ return(EXIT_FAILURE);
}
- return(EXIT_FAILURE);
}
diff --git a/archival/libunarchive/filter_accept_reject_list.c b/archival/libunarchive/filter_accept_reject_list.c
index c893dfc..21fecf1 100644
--- a/archival/libunarchive/filter_accept_reject_list.c
+++ b/archival/libunarchive/filter_accept_reject_list.c
@@ -2,33 +2,24 @@
#include <stdlib.h>
#include "unarchive.h"
-static char check_list(const llist_t *list, const char *filename)
-{
- if (list) {
- while (list) {
- if (fnmatch(list->data, filename, 0) == 0) {
- return(EXIT_SUCCESS);
- }
- list = list->link;
- }
- }
- return(EXIT_FAILURE);
-}
-
/*
* Accept names that are in the accept list
*/
extern char filter_accept_reject_list(const llist_t *accept_list, const llist_t *reject_list, const char *key)
{
+ const llist_t *accept_entry = find_list_entry(accept_list, key);
+ const llist_t *reject_entry = find_list_entry(reject_list, key);
+
/* Fail if an accept list was specified and the key wasnt in there */
- if ((accept_list) && (check_list(accept_list, key) == EXIT_FAILURE)) {
+ if (accept_list && (accept_entry == NULL)) {
return(EXIT_FAILURE);
}
/* If the key is in a reject list fail */
- if (check_list(reject_list, key) == EXIT_FAILURE) {
+ if (reject_entry) {
return(EXIT_FAILURE);
}
+ /* Accepted */
return(EXIT_SUCCESS);
}
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index bb0affe..e87eb77 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -47,6 +47,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
} tar;
long sum = 0;
long i;
+ char *tmp;
/* Align header */
archive_handle->offset += data_align(archive_handle->src_fd, archive_handle->offset, 512);
@@ -91,6 +92,11 @@ extern char get_header_tar(archive_handle_t *archive_handle)
} else {
file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name);
}
+ tmp = last_char_is(archive_handle->file_header->name, '/');
+ if (tmp) {
+ *tmp = '\0';
+ }
+
file_header->mode = strtol(tar.formated.mode, NULL, 8);
file_header->uid = strtol(tar.formated.uid, NULL, 8);
file_header->gid = strtol(tar.formated.gid, NULL, 8);
@@ -159,6 +165,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
archive_handle->action_header(archive_handle->file_header);
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->action_data(archive_handle);
+ archive_handle->passed = add_to_list(archive_handle->passed, archive_handle->file_header->name);
} else {
data_skip(archive_handle);
}