libarchive: do not extract unsafe symlinks unless $EXTRACT_UNSAFE_SYMLINKS=1

function                                             old     new   delta
unsafe_symlink_target                                  -     147    +147
unzip_main                                          2711    2732     +21
copy_file                                           1657    1678     +21
tar_main                                             999     971     -28
data_extract_all                                    1038     984     -54
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/2 up/down: 189/-82)           Total: 107 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2017-08-10 11:52:42 +02:00
parent 0cf64c8b5d
commit bc9bbeb2b8
9 changed files with 85 additions and 55 deletions

View File

@@ -64,9 +64,6 @@ typedef struct archive_handle_t {
/* Currently processed file's header */
file_header_t *file_header;
/* List of symlink placeholders */
llist_t *symlink_placeholders;
/* Process the header component, e.g. tar -t */
void FAST_FUNC (*action_header)(const file_header_t *);
@@ -200,6 +197,7 @@ void seek_by_jump(int fd, off_t amount) FAST_FUNC;
void seek_by_read(int fd, off_t amount) FAST_FUNC;
const char *strip_unsafe_prefix(const char *str) FAST_FUNC;
int unsafe_symlink_target(const char *target) FAST_FUNC;
void data_align(archive_handle_t *archive_handle, unsigned boundary) FAST_FUNC;
const llist_t *find_list_entry(const llist_t *list, const char *filename) FAST_FUNC;