Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
# Ideally this will be a compile/link time check, yet there's no obvious way
# how considering how old our minimum required cmake version is. The official
# cmake.org side does not host the manual pages even. Normally we can use
Expand Down
8 changes: 1 addition & 7 deletions cat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ IF(ENABLE_CAT)

# How to build bsdcat
ADD_EXECUTABLE(bsdcat ${bsdcat_SOURCES})
IF(ENABLE_CAT_SHARED)
TARGET_LINK_LIBRARIES(bsdcat archive ${ADDITIONAL_LIBS})
ELSE(ENABLE_CAT_SHARED)
TARGET_LINK_LIBRARIES(bsdcat archive_static ${ADDITIONAL_LIBS})
SET_TARGET_PROPERTIES(bsdcat PROPERTIES COMPILE_DEFINITIONS
LIBARCHIVE_STATIC)
ENDIF(ENABLE_CAT_SHARED)
TARGET_LINK_LIBRARIES(bsdcat LibArchive::LibArchive ${ADDITIONAL_LIBS})

# Installation rules
INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
Expand Down
8 changes: 1 addition & 7 deletions cpio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ IF(ENABLE_CPIO)

# How to build bsdcpio
ADD_EXECUTABLE(bsdcpio ${bsdcpio_SOURCES})
IF(ENABLE_CPIO_SHARED)
TARGET_LINK_LIBRARIES(bsdcpio archive ${ADDITIONAL_LIBS})
ELSE(ENABLE_CPIO_SHARED)
TARGET_LINK_LIBRARIES(bsdcpio archive_static ${ADDITIONAL_LIBS})
SET_TARGET_PROPERTIES(bsdcpio PROPERTIES COMPILE_DEFINITIONS
LIBARCHIVE_STATIC)
ENDIF(ENABLE_CPIO_SHARED)
TARGET_LINK_LIBRARIES(bsdcpio LibArchive::LibArchive)

# Installation rules
INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin)
Expand Down
6 changes: 3 additions & 3 deletions libarchive/archive_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ parse_option(const char **s, const char **m, const char **o, const char **v)
opt = *s;
val = "1";

p = strchr(opt, ',');
p = (char*)strchr(opt, ',');

if (p != NULL) {
*p = '\0';
Expand All @@ -192,14 +192,14 @@ parse_option(const char **s, const char **m, const char **o, const char **v)
return end;
}

p = strchr(opt, ':');
p = (char *)strchr(opt, ':');
if (p != NULL) {
*p = '\0';
mod = opt;
opt = ++p;
}

p = strchr(opt, '=');
p = (char*)strchr(opt, '=');
if (p != NULL) {
*p = '\0';
val = ++p;
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_pack_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ compare_format(const void *key, const void *element)
pack_t *
pack_find(const char *name)
{
struct format *format;
const struct format *format;

format = bsearch(name, formats,
sizeof(formats)/sizeof(formats[0]),
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_support_format_mtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ readline(struct archive_read *a, struct mtree *mtree, char **start,
ssize_t total_size = 0;
ssize_t find_off = 0;
const void *t;
void *nl;
const void *nl;
char *u;

/* Accumulate line in a line buffer. */
Expand Down
109 changes: 62 additions & 47 deletions libarchive/archive_read_support_format_tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct tar {
int pax_hdrcharset_binary;
int header_recursion_depth;
int64_t entry_bytes_remaining;
int64_t entry_data_start;
int64_t entry_offset;
int64_t entry_padding;
int64_t entry_bytes_unconsumed;
Expand Down Expand Up @@ -280,18 +281,6 @@ archive_read_support_format_tar(struct archive *_a)
return (ARCHIVE_OK);
}

static int64_t
client_seek_proxy(struct archive_read_filter *self, int64_t offset, int whence)
{
if (self->archive->client.seeker == NULL) {
archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
"Current client reader does not support seeking a device");
return (ARCHIVE_FAILED);
}
return (self->archive->client.seeker)(&self->archive->archive,
self->data, offset, whence);
}

static int
archive_read_format_tar_read_header(struct archive_read *a,
struct archive_entry *entry);
Expand All @@ -300,42 +289,66 @@ static int64_t
archive_read_format_tar_seek_data(struct archive_read *a, int64_t offset,
int whence)
{
struct tar *tar = (struct tar *)(a->format->data);
if (tar->entry_bytes_unconsumed) {
__archive_read_consume(a, tar->entry_bytes_unconsumed);
tar->entry_bytes_unconsumed = 0;
}
a->filter->avail = a->filter->client_avail = 0;
a->filter->next = a->filter->buffer;
a->filter->position = tar->entry_offset;
a->filter->end_of_file = 0;
(void)client_seek_proxy(a->filter, a->header_position, SEEK_SET);
archive_read_format_tar_read_header(a, a->entry);
int64_t client_offset;
(void)tar;
switch (whence)
{
case SEEK_CUR:
client_offset = a->archive.read_data_offset;
break;
case SEEK_END:
client_offset = a->header_position + tar->realsize;
break;
case SEEK_SET:
default:
client_offset = a->header_position;
struct tar *tar = (struct tar *)(a->format->data);
int64_t base_offset, target_offset, ret;
int sparse_count;
int64_t sparse_offset, sparse_length;

/*
* For regular tar entries, random access is only safe when the
* entry data is a single contiguous block in the archive.
*/
sparse_count = archive_entry_sparse_count(a->entry);
if (sparse_count > 0) {
if (sparse_count != 1 ||
archive_entry_sparse_reset(a->entry) != ARCHIVE_OK ||
archive_entry_sparse_next(a->entry, &sparse_offset,
&sparse_length) != ARCHIVE_OK ||
sparse_offset != 0 || sparse_length != tar->realsize) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Seeking of non-contiguous tar entries is unsupported");
return (ARCHIVE_FAILED);
}
}

switch (whence) {
case SEEK_CUR:
base_offset = a->archive.read_data_output_offset;
break;
case SEEK_END:
base_offset = tar->realsize;
break;
}
client_offset += offset;
if (client_offset < a->header_position) {
client_offset = a->header_position;
}
else if (client_offset > tar->realsize + a->header_position) {
client_offset = tar->realsize + a->header_position;
}
int64_t ret_val = __archive_read_seek(a, client_offset + 512, SEEK_SET) - 512 - a->header_position;
case SEEK_SET:
default:
base_offset = 0;
break;
}

target_offset = base_offset + offset;
if (target_offset < 0 || target_offset > tar->realsize) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Attempt to seek past beginning or end of tar data block");
return (ARCHIVE_FAILED);
}

ret = __archive_read_seek(
a, tar->entry_data_start + target_offset, SEEK_SET);
if (ret < ARCHIVE_OK)
return (ret);

gnu_clear_sparse_list(tar);
if (gnu_add_sparse_entry(a, tar, target_offset,
tar->realsize - target_offset) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
tar->entry_offset = target_offset;
tar->entry_bytes_remaining = tar->realsize - target_offset;
tar->entry_padding = 0x1ff & (-tar->realsize);
tar->entry_bytes_unconsumed = 0;

__archive_reset_read_data(&a->archive);
return ret_val;
a->archive.read_data_output_offset = target_offset;
a->archive.read_data_offset = target_offset;
return (target_offset);
}

static int
Expand Down Expand Up @@ -585,6 +598,7 @@ archive_read_format_tar_read_header(struct archive_read *a,
}

tar = (struct tar *)(a->format->data);
tar->entry_data_start = 0;
tar->entry_offset = 0;
gnu_clear_sparse_list(tar);
tar->realsize = -1; /* Mark this as "unset" */
Expand All @@ -604,6 +618,7 @@ archive_read_format_tar_read_header(struct archive_read *a,
r = tar_read_header(a, tar, entry, &unconsumed);

tar_flush_unconsumed(a, &unconsumed);
tar->entry_data_start = a->filter->position;

/*
* "non-sparse" files are really just sparse files with
Expand Down Expand Up @@ -2825,7 +2840,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
ssize_t total_size = 0;
const void *t;
const char *s;
void *p;
const void *p;

tar_flush_unconsumed(a, unconsumed);

Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_iso9660.c
Original file line number Diff line number Diff line change
Expand Up @@ -5521,7 +5521,7 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location)
static int
get_path_component(char *name, size_t n, const char *fn)
{
char *p;
const char *p;
size_t l;

p = strchr(fn, '/');
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_mtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ mtree_entry_find_child(struct mtree_entry *parent, const char *child_name)
static int
get_path_component(char *name, size_t n, const char *fn)
{
char *p;
const char *p;
size_t l;

p = strchr(fn, '/');
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_warc.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ _popul_ehdr(struct archive_string *tgt, size_t tsz, warc_essential_hdr_t hdr)
static const char _uri[] = "";
static const char _fil[] = "file://";
const char *u;
char *chk = strchr(hdr.tgturi, ':');
const char *chk = strchr(hdr.tgturi, ':');

if (chk != NULL && chk[1U] == '/' && chk[2U] == '/') {
/* yep, it's definitely a URI */
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_xar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ file_gen_utility_names(struct archive_write *a, struct file *file)
static int
get_path_component(char *name, int n, const char *fn)
{
char *p;
const char *p;
int l;

p = strchr(fn, '/');
Expand Down
3 changes: 1 addition & 2 deletions libarchive/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ IF(ENABLE_TEST)
# Register target
#
ADD_EXECUTABLE(libarchive_test ${libarchive_test_SOURCES})
TARGET_LINK_LIBRARIES(libarchive_test archive_static ${ADDITIONAL_LIBS})
TARGET_LINK_LIBRARIES(libarchive_test LibArchive::LibArchive ${ADDITIONAL_LIBS})
SET_PROPERTY(TARGET libarchive_test PROPERTY COMPILE_DEFINITIONS
LIBARCHIVE_STATIC LIST_H)

Expand Down Expand Up @@ -328,4 +328,3 @@ IF(ENABLE_TEST)
COMMAND libarchive_test -r ${CMAKE_CURRENT_SOURCE_DIR} -vv)
ADD_DEPENDENCIES(run_all_tests run_libarchive_test)
ENDIF(ENABLE_TEST)

Loading
Loading