Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
baulktar: 1.0.2 Sync zstd and libarchive
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Dec 18, 2020
1 parent bf44e8b commit 4a2869e
Show file tree
Hide file tree
Showing 90 changed files with 5,119 additions and 2,357 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ endif()

set(BAULKTAR_VERSION_MAJOR 1)
set(BAULKTAR_VERSION_MINOR 0)
set(BAULKTAR_VERSION_PATCH 0)
set(BAULKTAR_VERSION_PATCH 2)
set(PACKAGE_VERSION "${BAULKTAR_VERSION_MAJOR}.${BAULKTAR_VERSION_MINOR}.${BAULKTAR_VERSION_PATCH}")

set(CPACK_PACKAGE_NAME "BaulkTar")
Expand Down
3 changes: 2 additions & 1 deletion lib/libarchive.lock
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
https://github.com/libarchive/libarchive/tree/a79d542d458993282c5e6c3d2d41ac00fdf92453
#https://github.com/libarchive/libarchive/tree/833821f55b1807cac22a63a58b759a7802df2fb7
3.5.0
12 changes: 8 additions & 4 deletions lib/libarchive/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#ifndef ARCHIVE_VERSION_NUMBER
#define ARCHIVE_VERSION_NUMBER 3004004
#endif
#define ARCHIVE_VERSION_NUMBER 3005000

#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
Expand Down Expand Up @@ -157,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_ONLY_STRING "3.4.4dev"
#define ARCHIVE_VERSION_ONLY_STRING "3.5.0"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);

Expand Down Expand Up @@ -248,6 +246,8 @@ typedef int archive_open_callback(struct archive *, void *_client_data);

typedef int archive_close_callback(struct archive *, void *_client_data);

typedef int archive_free_callback(struct archive *, void *_client_data);

/* Switches from one client data object to the next/prev client data object.
* This is useful for reading from different data blocks such as a set of files
* that make up one large file.
Expand Down Expand Up @@ -820,9 +820,13 @@ __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const ch
__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
__LA_DECL int archive_write_zip_set_compression_store(struct archive *);
/* Deprecated; use archive_write_open2 instead */
__LA_DECL int archive_write_open(struct archive *, void *,
archive_open_callback *, archive_write_callback *,
archive_close_callback *);
__LA_DECL int archive_write_open2(struct archive *, void *,
archive_open_callback *, archive_write_callback *,
archive_close_callback *, archive_free_callback *);
__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
__LA_DECL int archive_write_open_filename_w(struct archive *,
Expand Down
23 changes: 23 additions & 0 deletions lib/libarchive/archive_cryptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,31 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
static int
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
{
#if NETTLE_VERSION_MAJOR < 3
aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
#else
switch(ctx->key_len) {
case AES128_KEY_SIZE:
aes128_set_encrypt_key(&ctx->ctx.c128, ctx->key);
aes128_encrypt(&ctx->ctx.c128, AES_BLOCK_SIZE, ctx->encr_buf,
ctx->nonce);
break;
case AES192_KEY_SIZE:
aes192_set_encrypt_key(&ctx->ctx.c192, ctx->key);
aes192_encrypt(&ctx->ctx.c192, AES_BLOCK_SIZE, ctx->encr_buf,
ctx->nonce);
break;
case AES256_KEY_SIZE:
aes256_set_encrypt_key(&ctx->ctx.c256, ctx->key);
aes256_encrypt(&ctx->ctx.c256, AES_BLOCK_SIZE, ctx->encr_buf,
ctx->nonce);
break;
default:
return -1;
break;
}
#endif
return 0;
}

Expand Down
9 changes: 9 additions & 0 deletions lib/libarchive/archive_cryptor_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,18 @@ typedef struct {
#include <nettle/pbkdf2.h>
#endif
#include <nettle/aes.h>
#include <nettle/version.h>

typedef struct {
#if NETTLE_VERSION_MAJOR < 3
struct aes_ctx ctx;
#else
union {
struct aes128_ctx c128;
struct aes192_ctx c192;
struct aes256_ctx c256;
} ctx;
#endif
uint8_t key[AES_MAX_KEY_SIZE];
unsigned key_len;
uint8_t nonce[AES_BLOCK_SIZE];
Expand Down
4 changes: 4 additions & 0 deletions lib/libarchive/archive_digest_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#ifndef __LIBARCHIVE_BUILD
#error This header is only to be used internally to libarchive.
#endif
#ifndef __LIBARCHIVE_CONFIG_H_INCLUDED
#error "Should have include config.h first!"
#endif

/*
* Crypto support in various Operating Systems:
*
Expand Down
2 changes: 1 addition & 1 deletion lib/libarchive/archive_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED

/* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3004004
#define ARCHIVE_VERSION_NUMBER 3005000

/*
* Note: archive_entry.h is for use outside of libarchive; the
Expand Down
2 changes: 1 addition & 1 deletion lib/libarchive/archive_ppmd7.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */

#include "archive_platform.h"

#include <memory.h>
#include <stdlib.h>

#include "archive_ppmd7_private.h"

Expand Down
48 changes: 44 additions & 4 deletions lib/libarchive/archive_read_disk_entry_from_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ __FBSDID("$FreeBSD");

static int setup_mac_metadata(struct archive_read_disk *,
struct archive_entry *, int *fd);
#ifdef ARCHIVE_XATTR_FREEBSD
static int setup_xattrs_namespace(struct archive_read_disk *,
struct archive_entry *, int *, int);
#endif
static int setup_xattrs(struct archive_read_disk *,
struct archive_entry *, int *fd);
static int setup_sparse(struct archive_read_disk *,
Expand Down Expand Up @@ -701,14 +705,13 @@ setup_xattr(struct archive_read_disk *a, struct archive_entry *entry,
}

static int
setup_xattrs(struct archive_read_disk *a,
struct archive_entry *entry, int *fd)
setup_xattrs_namespace(struct archive_read_disk *a,
struct archive_entry *entry, int *fd, int namespace)
{
char buff[512];
char *list, *p;
ssize_t list_size;
const char *path;
int namespace = EXTATTR_NAMESPACE_USER;

path = NULL;

Expand All @@ -727,6 +730,8 @@ setup_xattrs(struct archive_read_disk *a,

if (list_size == -1 && errno == EOPNOTSUPP)
return (ARCHIVE_OK);
if (list_size == -1 && errno == EPERM)
return (ARCHIVE_OK);
if (list_size == -1) {
archive_set_error(&a->archive, errno,
"Couldn't list extended attributes");
Expand Down Expand Up @@ -760,7 +765,17 @@ setup_xattrs(struct archive_read_disk *a,
size_t len = 255 & (int)*p;
char *name;

strcpy(buff, "user.");
if (namespace == EXTATTR_NAMESPACE_SYSTEM) {
if (!strcmp(p + 1, "nfs4.acl") ||
!strcmp(p + 1, "posix1e.acl_access") ||
!strcmp(p + 1, "posix1e.acl_default")) {
p += 1 + len;
continue;
}
strcpy(buff, "system.");
} else {
strcpy(buff, "user.");
}
name = buff + strlen(buff);
memcpy(name, p + 1, len);
name[len] = '\0';
Expand All @@ -772,6 +787,31 @@ setup_xattrs(struct archive_read_disk *a,
return (ARCHIVE_OK);
}

static int
setup_xattrs(struct archive_read_disk *a,
struct archive_entry *entry, int *fd)
{
int namespaces[2];
int i, res;

namespaces[0] = EXTATTR_NAMESPACE_USER;
namespaces[1] = EXTATTR_NAMESPACE_SYSTEM;

for (i = 0; i < 2; i++) {
res = setup_xattrs_namespace(a, entry, fd,
namespaces[i]);
switch (res) {
case (ARCHIVE_OK):
case (ARCHIVE_WARN):
break;
default:
return (res);
}
}

return (ARCHIVE_OK);
}

#else

/*
Expand Down
2 changes: 1 addition & 1 deletion lib/libarchive/archive_read_support_format_cab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ cab_checksum_finish(struct archive_read *a)
cfdata->memimage + CFDATA_cbData, l, cfdata->sum_calculated);
if (cfdata->sum_calculated != cfdata->sum) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Checksum error CFDATA[%d] %x:%x in %d bytes",
"Checksum error CFDATA[%d] %" PRIx32 ":%" PRIx32 " in %d bytes",
cab->entry_cffolder->cfdata_index -1,
cfdata->sum, cfdata->sum_calculated,
cfdata->compressed_size);
Expand Down
14 changes: 10 additions & 4 deletions lib/libarchive/archive_read_support_format_rar.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
#undef minimum
#define minimum(a, b) ((a)<(b)?(a):(b))

/* Stack overflow check */
#define MAX_COMPRESS_DEPTH 1024

/* Fields common to all headers */
struct rar_header
{
Expand Down Expand Up @@ -340,7 +343,7 @@ static int read_symlink_stored(struct archive_read *, struct archive_entry *,
static int read_data_stored(struct archive_read *, const void **, size_t *,
int64_t *);
static int read_data_compressed(struct archive_read *, const void **, size_t *,
int64_t *);
int64_t *, size_t);
static int rar_br_preparation(struct archive_read *, struct rar_br *);
static int parse_codes(struct archive_read *);
static void free_codes(struct archive_read *);
Expand Down Expand Up @@ -1026,7 +1029,7 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
case COMPRESS_METHOD_NORMAL:
case COMPRESS_METHOD_GOOD:
case COMPRESS_METHOD_BEST:
ret = read_data_compressed(a, buff, size, offset);
ret = read_data_compressed(a, buff, size, offset, 0);
if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN) {
__archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
rar->start_new_table = 1;
Expand Down Expand Up @@ -1883,8 +1886,11 @@ read_data_stored(struct archive_read *a, const void **buff, size_t *size,

static int
read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
int64_t *offset)
int64_t *offset, size_t looper)
{
if (looper++ > MAX_COMPRESS_DEPTH)
return (ARCHIVE_FATAL);

struct rar *rar;
int64_t start, end, actualend;
size_t bs;
Expand Down Expand Up @@ -1982,7 +1988,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
{
case 0:
rar->start_new_table = 1;
return read_data_compressed(a, buff, size, offset);
return read_data_compressed(a, buff, size, offset, looper);

case 2:
rar->ppmd_eod = 1;/* End Of ppmd Data. */
Expand Down
4 changes: 2 additions & 2 deletions lib/libarchive/archive_read_support_format_rar5.c
Original file line number Diff line number Diff line change
Expand Up @@ -3831,7 +3831,7 @@ static int verify_checksums(struct archive_read* a) {

DEBUG_CODE {
printf("Checksum error: CRC32 "
"(was: %08x, expected: %08x)\n",
"(was: %08" PRIx32 ", expected: %08" PRIx32 ")\n",
rar->file.calculated_crc32,
rar->file.stored_crc32);
}
Expand All @@ -3845,7 +3845,7 @@ static int verify_checksums(struct archive_read* a) {
} else {
DEBUG_CODE {
printf("Checksum OK: CRC32 "
"(%08x/%08x)\n",
"(%08" PRIx32 "/%08" PRIx32 ")\n",
rar->file.stored_crc32,
rar->file.calculated_crc32);
}
Expand Down
Loading

0 comments on commit 4a2869e

Please sign in to comment.