mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 09:59:20 -05:00
Merge topic 'update-libarchive'
ddb72eb3e6Merge branch 'upstream-LibArchive' into update-libarchivead48f00c30LibArchive 2024-10-13 (b439d586)e048b0cc94libarchive: Update script to get 3.7.7 Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !10011
This commit is contained in:
@@ -8,7 +8,7 @@ readonly name="LibArchive"
|
||||
readonly ownership="LibArchive Upstream <libarchive-discuss@googlegroups.com>"
|
||||
readonly subtree="Utilities/cmlibarchive"
|
||||
readonly repo="https://github.com/libarchive/libarchive.git"
|
||||
readonly tag="v3.7.5"
|
||||
readonly tag="v3.7.7"
|
||||
readonly shortlog=false
|
||||
readonly paths="
|
||||
CMakeLists.txt
|
||||
|
||||
@@ -908,6 +908,14 @@ IF(NOT OPENSSL_FOUND)
|
||||
ENDIF(LIBMD_FOUND)
|
||||
ENDIF(NOT OPENSSL_FOUND)
|
||||
|
||||
# libbsd for readpassphrase on Haiku
|
||||
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Haiku")
|
||||
MESSAGE(STATUS "Adding libbsd for Haiku")
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "bsd")
|
||||
FIND_LIBRARY(LIBBSD_LIBRARY NAMES bsd)
|
||||
LIST(APPEND ADDITIONAL_LIBS ${LIBBSD_LIBRARY})
|
||||
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "Haiku")
|
||||
|
||||
#
|
||||
# How to prove that CRYPTO functions, which have several names on various
|
||||
# platforms, just see if archive_digest.c can compile and link against
|
||||
|
||||
@@ -1 +1 @@
|
||||
3007005
|
||||
3007007
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
|
||||
*/
|
||||
/* Note: Compiler will complain if this does not match archive_entry.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3007005
|
||||
#define ARCHIVE_VERSION_NUMBER 3007007
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stddef.h> /* for wchar_t */
|
||||
@@ -152,7 +152,7 @@ __LA_DECL int archive_version_number(void);
|
||||
/*
|
||||
* Textual name/version of the library, useful for version displays.
|
||||
*/
|
||||
#define ARCHIVE_VERSION_ONLY_STRING "3.7.5"
|
||||
#define ARCHIVE_VERSION_ONLY_STRING "3.7.7"
|
||||
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
|
||||
__LA_DECL const char * archive_version_string(void);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ static int archive_acl_add_entry_len_l(struct archive_acl *acl,
|
||||
int type, int permset, int tag, int id, const char *name,
|
||||
size_t len, struct archive_string_conv *sc);
|
||||
static int archive_acl_text_want_type(struct archive_acl *acl, int flags);
|
||||
static ssize_t archive_acl_text_len(struct archive_acl *acl, int want_type,
|
||||
static size_t archive_acl_text_len(struct archive_acl *acl, int want_type,
|
||||
int flags, int wide, struct archive *a,
|
||||
struct archive_string_conv *sc);
|
||||
static int isint_w(const wchar_t *start, const wchar_t *end, int *result);
|
||||
@@ -350,7 +350,7 @@ acl_new_entry(struct archive_acl *acl,
|
||||
}
|
||||
|
||||
/* Add a new entry to the end of the list. */
|
||||
ap = (struct archive_acl_entry *)calloc(1, sizeof(*ap));
|
||||
ap = calloc(1, sizeof(*ap));
|
||||
if (ap == NULL)
|
||||
return (NULL);
|
||||
if (aq == NULL)
|
||||
@@ -532,14 +532,14 @@ archive_acl_text_want_type(struct archive_acl *acl, int flags)
|
||||
/*
|
||||
* Calculate ACL text string length
|
||||
*/
|
||||
static ssize_t
|
||||
static size_t
|
||||
archive_acl_text_len(struct archive_acl *acl, int want_type, int flags,
|
||||
int wide, struct archive *a, struct archive_string_conv *sc) {
|
||||
struct archive_acl_entry *ap;
|
||||
const char *name;
|
||||
const wchar_t *wname;
|
||||
int count, idlen, tmp, r;
|
||||
ssize_t length;
|
||||
size_t length;
|
||||
size_t len;
|
||||
|
||||
count = 0;
|
||||
@@ -668,7 +668,7 @@ archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags,
|
||||
struct archive *a)
|
||||
{
|
||||
int count;
|
||||
ssize_t length;
|
||||
size_t length;
|
||||
size_t len;
|
||||
const wchar_t *wname;
|
||||
const wchar_t *prefix;
|
||||
@@ -697,7 +697,7 @@ archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags,
|
||||
separator = L'\n';
|
||||
|
||||
/* Now, allocate the string and actually populate it. */
|
||||
wp = ws = (wchar_t *)malloc(length * sizeof(wchar_t));
|
||||
wp = ws = malloc(length * sizeof(*wp));
|
||||
if (wp == NULL) {
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
@@ -759,7 +759,7 @@ archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags,
|
||||
|
||||
len = wcslen(ws);
|
||||
|
||||
if ((ssize_t)len > (length - 1))
|
||||
if (len > length - 1)
|
||||
__archive_errx(1, "Buffer overrun");
|
||||
|
||||
if (text_len != NULL)
|
||||
@@ -901,7 +901,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags,
|
||||
struct archive_string_conv *sc)
|
||||
{
|
||||
int count;
|
||||
ssize_t length;
|
||||
size_t length;
|
||||
size_t len;
|
||||
const char *name;
|
||||
const char *prefix;
|
||||
@@ -930,7 +930,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags,
|
||||
separator = '\n';
|
||||
|
||||
/* Now, allocate the string and actually populate it. */
|
||||
p = s = (char *)malloc(length * sizeof(char));
|
||||
p = s = malloc(length * sizeof(*p));
|
||||
if (p == NULL) {
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
@@ -994,7 +994,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags,
|
||||
|
||||
len = strlen(s);
|
||||
|
||||
if ((ssize_t)len > (length - 1))
|
||||
if (len > length - 1)
|
||||
__archive_errx(1, "Buffer overrun");
|
||||
|
||||
if (text_len != NULL)
|
||||
|
||||
@@ -57,7 +57,7 @@ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Bcrypt.lib")
|
||||
#endif
|
||||
@@ -197,7 +197,7 @@ aes_ctr_release(archive_crypto_ctx *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
|
||||
static int
|
||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef struct {
|
||||
unsigned encr_pos;
|
||||
} archive_crypto_ctx;
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
#include <bcrypt.h>
|
||||
|
||||
/* Common in other bcrypt implementations, but missing from VS2008. */
|
||||
|
||||
@@ -263,7 +263,7 @@ archive_entry_new2(struct archive *a)
|
||||
{
|
||||
struct archive_entry *entry;
|
||||
|
||||
entry = (struct archive_entry *)calloc(1, sizeof(*entry));
|
||||
entry = calloc(1, sizeof(*entry));
|
||||
if (entry == NULL)
|
||||
return (NULL);
|
||||
entry->archive = a;
|
||||
@@ -2095,7 +2095,7 @@ ae_fflagstostr(unsigned long bitset, unsigned long bitclear)
|
||||
|
||||
if (length == 0)
|
||||
return (NULL);
|
||||
string = (char *)malloc(length);
|
||||
string = malloc(length);
|
||||
if (string == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define ARCHIVE_ENTRY_H_INCLUDED
|
||||
|
||||
/* Note: Compiler will complain if this does not match archive.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3007005
|
||||
#define ARCHIVE_VERSION_NUMBER 3007007
|
||||
|
||||
/*
|
||||
* Note: archive_entry.h is for use outside of libarchive; the
|
||||
|
||||
@@ -76,7 +76,7 @@ archive_entry_sparse_add_entry(struct archive_entry *entry,
|
||||
}
|
||||
}
|
||||
|
||||
if ((sp = (struct ae_sparse *)malloc(sizeof(*sp))) == NULL)
|
||||
if ((sp = malloc(sizeof(*sp))) == NULL)
|
||||
/* XXX Error XXX */
|
||||
return;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ archive_entry_xattr_add_entry(struct archive_entry *entry,
|
||||
{
|
||||
struct ae_xattr *xp;
|
||||
|
||||
if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
|
||||
if ((xp = malloc(sizeof(struct ae_xattr))) == NULL)
|
||||
__archive_errx(1, "Out of memory");
|
||||
|
||||
if ((xp->name = strdup(name)) == NULL)
|
||||
|
||||
@@ -74,7 +74,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
}
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
|
||||
#ifndef BCRYPT_HASH_REUSABLE_FLAG
|
||||
# define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
|
||||
|
||||
@@ -52,7 +52,7 @@ int __libarchive_hmac_build_hack(void);
|
||||
|
||||
typedef CCHmacContext archive_hmac_sha1_ctx;
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
#include <bcrypt.h>
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -220,7 +220,7 @@ archive_match_new(void)
|
||||
{
|
||||
struct archive_match *a;
|
||||
|
||||
a = (struct archive_match *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_MATCH_MAGIC;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <string.h> /* memset */
|
||||
static inline EVP_MD_CTX *EVP_MD_CTX_new(void)
|
||||
{
|
||||
EVP_MD_CTX *ctx = (EVP_MD_CTX *)calloc(1, sizeof(EVP_MD_CTX));
|
||||
EVP_MD_CTX *ctx = calloc(1, sizeof(EVP_MD_CTX));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <string.h> /* memset */
|
||||
static inline HMAC_CTX *HMAC_CTX_new(void)
|
||||
{
|
||||
HMAC_CTX *ctx = (HMAC_CTX *)calloc(1, sizeof(HMAC_CTX));
|
||||
HMAC_CTX *ctx = calloc(1, sizeof(HMAC_CTX));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ static Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size)
|
||||
#else
|
||||
4 - (size & 3);
|
||||
#endif
|
||||
if ((p->Base = (Byte *)malloc(p->AlignOffset + size
|
||||
if ((p->Base = malloc(p->AlignOffset + size
|
||||
#ifndef PPMD_32BIT
|
||||
+ UNIT_SIZE
|
||||
#endif
|
||||
|
||||
@@ -111,7 +111,7 @@ Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size)
|
||||
#else
|
||||
4 - (size & 3);
|
||||
#endif
|
||||
if ((p->Base = (Byte *)malloc(p->AlignOffset + size)) == 0)
|
||||
if ((p->Base = malloc(p->AlignOffset + size)) == 0)
|
||||
return False;
|
||||
p->Size = size;
|
||||
}
|
||||
|
||||
@@ -160,9 +160,9 @@ __LA_NORETURN void __archive_errx(int retvalue, const char *msg);
|
||||
void __archive_ensure_cloexec_flag(int fd);
|
||||
int __archive_mktemp(const char *tmpdir);
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
int __archive_mkstemp(wchar_t *template);
|
||||
int __archive_mkstemp(wchar_t *templates);
|
||||
#else
|
||||
int __archive_mkstemp(char *template);
|
||||
int __archive_mkstemp(char *templates);
|
||||
#endif
|
||||
|
||||
int __archive_clean(struct archive *);
|
||||
|
||||
@@ -92,7 +92,7 @@ archive_read_new(void)
|
||||
{
|
||||
struct archive_read *a;
|
||||
|
||||
a = (struct archive_read *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_READ_MAGIC;
|
||||
@@ -582,7 +582,7 @@ choose_filters(struct archive_read *a)
|
||||
}
|
||||
|
||||
filter
|
||||
= (struct archive_read_filter *)calloc(1, sizeof(*filter));
|
||||
= calloc(1, sizeof(*filter));
|
||||
if (filter == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
filter->bidder = best_bidder;
|
||||
@@ -1451,7 +1451,7 @@ __archive_read_filter_ahead(struct archive_read_filter *filter,
|
||||
s = t;
|
||||
}
|
||||
/* Now s >= min, so allocate a new buffer. */
|
||||
p = (char *)malloc(s);
|
||||
p = malloc(s);
|
||||
if (p == NULL) {
|
||||
archive_set_error(
|
||||
&filter->archive->archive,
|
||||
|
||||
@@ -123,8 +123,7 @@ archive_read_append_filter(struct archive *_a, int code)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
filter
|
||||
= (struct archive_read_filter *)calloc(1, sizeof(*filter));
|
||||
filter = calloc(1, sizeof(*filter));
|
||||
if (filter == NULL)
|
||||
{
|
||||
archive_set_error(&a->archive, ENOMEM, "Out of memory");
|
||||
@@ -180,8 +179,7 @@ archive_read_append_filter_program_signature(struct archive *_a,
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
filter
|
||||
= (struct archive_read_filter *)calloc(1, sizeof(*filter));
|
||||
filter = calloc(1, sizeof(*filter));
|
||||
if (filter == NULL)
|
||||
{
|
||||
archive_set_error(&a->archive, ENOMEM, "Out of memory");
|
||||
|
||||
@@ -455,7 +455,7 @@ archive_read_disk_new(void)
|
||||
{
|
||||
struct archive_read_disk *a;
|
||||
|
||||
a = (struct archive_read_disk *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_READ_DISK_MAGIC;
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
/* Old SDKs do not provide IO_REPARSE_TAG_SYMLINK */
|
||||
#define IO_REPARSE_TAG_SYMLINK 0xA000000CL
|
||||
#endif
|
||||
/* To deal with absolute symlink isuues */
|
||||
#define START_ABSOLUTE_SYMLINK_REPARSE L"\\??\\"
|
||||
|
||||
/*-
|
||||
* This is a new directory-walking system that addresses a number
|
||||
@@ -375,7 +377,7 @@ la_linkname_from_handle(HANDLE h, wchar_t **linkname, int *linktype)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
tbuf = malloc(len + 1 * sizeof(wchar_t));
|
||||
tbuf = malloc(len + sizeof(wchar_t));
|
||||
if (tbuf == NULL) {
|
||||
free(indata);
|
||||
return (-1);
|
||||
@@ -386,18 +388,21 @@ la_linkname_from_handle(HANDLE h, wchar_t **linkname, int *linktype)
|
||||
free(indata);
|
||||
|
||||
tbuf[len / sizeof(wchar_t)] = L'\0';
|
||||
if (wcsncmp(tbuf, START_ABSOLUTE_SYMLINK_REPARSE, 4) == 0) {
|
||||
/* Absolute symlink, so we'll change the NT path into a verbatim one */
|
||||
tbuf[1] = L'\\';
|
||||
} else {
|
||||
/* Relative symlink, so we can translate backslashes to slashes */
|
||||
wchar_t *temp = tbuf;
|
||||
do {
|
||||
if (*temp == L'\\')
|
||||
*temp = L'/';
|
||||
temp++;
|
||||
} while(*temp != L'\0');
|
||||
}
|
||||
|
||||
*linkname = tbuf;
|
||||
|
||||
/*
|
||||
* Translate backslashes to slashes for libarchive internal use
|
||||
*/
|
||||
while(*tbuf != L'\0') {
|
||||
if (*tbuf == L'\\')
|
||||
*tbuf = L'/';
|
||||
tbuf++;
|
||||
}
|
||||
|
||||
if ((st.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
*linktype = AE_SYMLINK_TYPE_FILE;
|
||||
else
|
||||
@@ -538,7 +543,7 @@ archive_read_disk_new(void)
|
||||
{
|
||||
struct archive_read_disk *a;
|
||||
|
||||
a = (struct archive_read_disk *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_READ_DISK_MAGIC;
|
||||
@@ -2473,7 +2478,7 @@ setup_sparse_from_disk(struct archive_read_disk *a,
|
||||
range.FileOffset.QuadPart = 0;
|
||||
range.Length.QuadPart = entry_size;
|
||||
outranges_size = 2048;
|
||||
outranges = (FILE_ALLOCATED_RANGE_BUFFER *)malloc(outranges_size);
|
||||
outranges = malloc(outranges_size);
|
||||
if (outranges == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Couldn't allocate memory");
|
||||
|
||||
@@ -51,7 +51,7 @@ struct archive_read_extract *
|
||||
__archive_read_get_extract(struct archive_read *a)
|
||||
{
|
||||
if (a->extract == NULL) {
|
||||
a->extract = (struct archive_read_extract *)calloc(1, sizeof(*a->extract));
|
||||
a->extract = calloc(1, sizeof(*a->extract));
|
||||
if (a->extract == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't extract");
|
||||
return (NULL);
|
||||
|
||||
@@ -74,7 +74,7 @@ archive_read_open_fd(struct archive *a, int fd, size_t block_size)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
mine = (struct read_fd_data *)calloc(1, sizeof(*mine));
|
||||
mine = calloc(1, sizeof(*mine));
|
||||
b = malloc(block_size);
|
||||
if (mine == NULL || b == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
|
||||
@@ -69,7 +69,7 @@ archive_read_open_FILE(struct archive *a, FILE *f)
|
||||
void *b;
|
||||
|
||||
archive_clear_error(a);
|
||||
mine = (struct read_FILE_data *)malloc(sizeof(*mine));
|
||||
mine = malloc(sizeof(*mine));
|
||||
b = malloc(block_size);
|
||||
if (mine == NULL || b == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
|
||||
@@ -122,7 +122,7 @@ archive_read_open_filenames(struct archive *a, const char **filenames,
|
||||
{
|
||||
if (filename == NULL)
|
||||
filename = "";
|
||||
mine = (struct read_file_data *)calloc(1,
|
||||
mine = calloc(1,
|
||||
sizeof(*mine) + strlen(filename));
|
||||
if (mine == NULL)
|
||||
goto no_memory;
|
||||
@@ -175,7 +175,7 @@ archive_read_open_filenames_w(struct archive *a, const wchar_t **wfilenames,
|
||||
{
|
||||
if (wfilename == NULL)
|
||||
wfilename = L"";
|
||||
mine = (struct read_file_data *)calloc(1,
|
||||
mine = calloc(1,
|
||||
sizeof(*mine) + wcslen(wfilename) * sizeof(wchar_t));
|
||||
if (mine == NULL)
|
||||
goto no_memory;
|
||||
|
||||
@@ -69,7 +69,7 @@ archive_read_open_memory2(struct archive *a, const void *buff,
|
||||
{
|
||||
struct read_memory_data *mine;
|
||||
|
||||
mine = (struct read_memory_data *)calloc(1, sizeof(*mine));
|
||||
mine = calloc(1, sizeof(*mine));
|
||||
if (mine == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -190,8 +190,8 @@ bzip2_reader_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_BZIP2;
|
||||
self->name = "bzip2";
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
out_block = (unsigned char *)malloc(out_block_size);
|
||||
state = calloc(1, sizeof(*state));
|
||||
out_block = malloc(out_block_size);
|
||||
if (state == NULL || out_block == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
"Can't allocate data for bzip2 decompression");
|
||||
|
||||
@@ -217,7 +217,7 @@ compress_bidder_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_COMPRESS;
|
||||
self->name = "compress (.Z)";
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
state = calloc(1, sizeof(*state));
|
||||
out_block = malloc(out_block_size);
|
||||
if (state == NULL || out_block == NULL) {
|
||||
free(out_block);
|
||||
|
||||
@@ -123,6 +123,8 @@ archive_read_support_filter_gzip(struct archive *_a)
|
||||
* number of bytes in header. If pbits is non-NULL, it receives a
|
||||
* count of bits verified, suitable for use by bidder.
|
||||
*/
|
||||
#define MAX_FILENAME_LENGTH (1024 * 1024L)
|
||||
#define MAX_COMMENT_LENGTH (1024 * 1024L)
|
||||
static ssize_t
|
||||
peek_at_header(struct archive_read_filter *filter, int *pbits,
|
||||
#ifdef HAVE_ZLIB_H
|
||||
@@ -180,9 +182,13 @@ peek_at_header(struct archive_read_filter *filter, int *pbits,
|
||||
#endif
|
||||
do {
|
||||
++len;
|
||||
if (avail < len)
|
||||
if (avail < len) {
|
||||
if (avail > MAX_FILENAME_LENGTH) {
|
||||
return (0);
|
||||
}
|
||||
p = __archive_read_filter_ahead(filter,
|
||||
len, &avail);
|
||||
}
|
||||
if (p == NULL)
|
||||
return (0);
|
||||
} while (p[len - 1] != 0);
|
||||
@@ -200,9 +206,13 @@ peek_at_header(struct archive_read_filter *filter, int *pbits,
|
||||
if (header_flags & 16) {
|
||||
do {
|
||||
++len;
|
||||
if (avail < len)
|
||||
if (avail < len) {
|
||||
if (avail > MAX_COMMENT_LENGTH) {
|
||||
return (0);
|
||||
}
|
||||
p = __archive_read_filter_ahead(filter,
|
||||
len, &avail);
|
||||
}
|
||||
if (p == NULL)
|
||||
return (0);
|
||||
} while (p[len - 1] != 0);
|
||||
@@ -307,8 +317,8 @@ gzip_bidder_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_GZIP;
|
||||
self->name = "gzip";
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
out_block = (unsigned char *)malloc(out_block_size);
|
||||
state = calloc(1, sizeof(*state));
|
||||
out_block = malloc(out_block_size);
|
||||
if (state == NULL || out_block == NULL) {
|
||||
free(out_block);
|
||||
free(state);
|
||||
|
||||
@@ -223,7 +223,7 @@ lz4_reader_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_LZ4;
|
||||
self->name = "lz4";
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
"Can't allocate data for lz4 decompression");
|
||||
@@ -248,7 +248,7 @@ lz4_allocate_out_block(struct archive_read_filter *self)
|
||||
out_block_size += 64 * 1024;
|
||||
if (state->out_block_size < out_block_size) {
|
||||
free(state->out_block);
|
||||
out_block = (unsigned char *)malloc(out_block_size);
|
||||
out_block = malloc(out_block_size);
|
||||
state->out_block_size = out_block_size;
|
||||
if (out_block == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
@@ -271,7 +271,7 @@ lz4_allocate_out_block_for_legacy(struct archive_read_filter *self)
|
||||
|
||||
if (state->out_block_size < out_block_size) {
|
||||
free(state->out_block);
|
||||
out_block = (unsigned char *)malloc(out_block_size);
|
||||
out_block = malloc(out_block_size);
|
||||
state->out_block_size = out_block_size;
|
||||
if (out_block == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
|
||||
@@ -185,7 +185,7 @@ lzop_bidder_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_LZOP;
|
||||
self->name = "lzop";
|
||||
|
||||
state = (struct read_lzop *)calloc(1, sizeof(*state));
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
"Can't allocate data for lzop decompression");
|
||||
|
||||
@@ -139,7 +139,7 @@ archive_read_support_filter_program_signature(struct archive *_a,
|
||||
/*
|
||||
* Allocate our private state.
|
||||
*/
|
||||
state = (struct program_bidder *)calloc(1, sizeof (*state));
|
||||
state = calloc(1, sizeof (*state));
|
||||
if (state == NULL)
|
||||
goto memerr;
|
||||
state->cmd = strdup(cmd);
|
||||
@@ -398,8 +398,8 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd)
|
||||
size_t l;
|
||||
|
||||
l = strlen(prefix) + strlen(cmd) + 1;
|
||||
state = (struct program_filter *)calloc(1, sizeof(*state));
|
||||
out_buf = (char *)malloc(out_buf_len);
|
||||
state = calloc(1, sizeof(*state));
|
||||
out_buf = malloc(out_buf_len);
|
||||
if (state == NULL || out_buf == NULL ||
|
||||
archive_string_ensure(&state->description, l) == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
|
||||
@@ -144,7 +144,7 @@ rpm_bidder_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_RPM;
|
||||
self->name = "rpm";
|
||||
|
||||
rpm = (struct rpm *)calloc(1, sizeof(*rpm));
|
||||
rpm = calloc(1, sizeof(*rpm));
|
||||
if (rpm == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
"Can't allocate data for rpm");
|
||||
|
||||
@@ -379,7 +379,7 @@ uudecode_bidder_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_UU;
|
||||
self->name = "uu";
|
||||
|
||||
uudecode = (struct uudecode *)calloc(1, sizeof(*uudecode));
|
||||
uudecode = calloc(1, sizeof(*uudecode));
|
||||
out_buff = malloc(OUT_BUFF_SIZE);
|
||||
in_buff = malloc(IN_BUFF_SIZE);
|
||||
if (uudecode == NULL || out_buff == NULL || in_buff == NULL) {
|
||||
|
||||
@@ -476,8 +476,8 @@ xz_lzma_bidder_init(struct archive_read_filter *self)
|
||||
struct private_data *state;
|
||||
int ret;
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
out_block = (unsigned char *)malloc(out_block_size);
|
||||
state = calloc(1, sizeof(*state));
|
||||
out_block = malloc(out_block_size);
|
||||
if (state == NULL || out_block == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
"Can't allocate data for xz decompression");
|
||||
|
||||
@@ -175,8 +175,8 @@ zstd_bidder_init(struct archive_read_filter *self)
|
||||
self->code = ARCHIVE_FILTER_ZSTD;
|
||||
self->name = "zstd";
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
out_block = (unsigned char *)malloc(out_block_size);
|
||||
state = calloc(1, sizeof(*state));
|
||||
out_block = malloc(out_block_size);
|
||||
dstream = ZSTD_createDStream();
|
||||
|
||||
if (state == NULL || out_block == NULL || dstream == NULL) {
|
||||
|
||||
@@ -771,29 +771,27 @@ archive_read_format_7zip_read_header(struct archive_read *a,
|
||||
|
||||
if (zip_entry->attr & supported_attrs) {
|
||||
char *fflags_text, *ptr;
|
||||
/* allocate for "rdonly,hidden,system," */
|
||||
fflags_text = malloc(22 * sizeof(char));
|
||||
/* allocate for ",rdonly,hidden,system" */
|
||||
fflags_text = malloc(22 * sizeof(*fflags_text));
|
||||
if (fflags_text != NULL) {
|
||||
ptr = fflags_text;
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_READONLY) {
|
||||
strcpy(ptr, "rdonly,");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_HIDDEN) {
|
||||
strcpy(ptr, "hidden,");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_SYSTEM) {
|
||||
strcpy(ptr, "system,");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (ptr > fflags_text) {
|
||||
/* Delete trailing comma */
|
||||
*(ptr - 1) = '\0';
|
||||
archive_entry_copy_fflags_text(entry,
|
||||
fflags_text);
|
||||
}
|
||||
free(fflags_text);
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_READONLY) {
|
||||
strcpy(ptr, ",rdonly");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_HIDDEN) {
|
||||
strcpy(ptr, ",hidden");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_SYSTEM) {
|
||||
strcpy(ptr, ",system");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (ptr > fflags_text) {
|
||||
archive_entry_copy_fflags_text(entry,
|
||||
fflags_text + 1);
|
||||
}
|
||||
free(fflags_text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -842,9 +840,20 @@ archive_read_format_7zip_read_header(struct archive_read *a,
|
||||
zip_entry->mode |= AE_IFREG;
|
||||
archive_entry_set_mode(entry, zip_entry->mode);
|
||||
} else {
|
||||
struct archive_string_conv* utf8_conv;
|
||||
|
||||
symname[symsize] = '\0';
|
||||
archive_entry_copy_symlink(entry,
|
||||
(const char *)symname);
|
||||
|
||||
/* Symbolic links are embedded as UTF-8 strings */
|
||||
utf8_conv = archive_string_conversion_from_charset(&a->archive,
|
||||
"UTF-8", 1);
|
||||
if (utf8_conv == NULL) {
|
||||
free(symname);
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
archive_entry_copy_symlink_l(entry, (const char*)symname, symsize,
|
||||
utf8_conv);
|
||||
}
|
||||
free(symname);
|
||||
archive_entry_set_size(entry, 0);
|
||||
|
||||
@@ -103,7 +103,7 @@ archive_read_support_format_ar(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_ar");
|
||||
|
||||
ar = (struct ar *)calloc(1, sizeof(*ar));
|
||||
ar = calloc(1, sizeof(*ar));
|
||||
if (ar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate ar data");
|
||||
@@ -368,7 +368,7 @@ _ar_read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
/* Store it in the entry. */
|
||||
p = (char *)malloc(bsd_name_length + 1);
|
||||
p = malloc(bsd_name_length + 1);
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate fname buffer");
|
||||
|
||||
@@ -356,7 +356,7 @@ archive_read_support_format_cab(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_cab");
|
||||
|
||||
cab = (struct cab *)calloc(1, sizeof(*cab));
|
||||
cab = calloc(1, sizeof(*cab));
|
||||
if (cab == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate CAB data");
|
||||
@@ -717,7 +717,7 @@ cab_read_header(struct archive_read *a)
|
||||
/*
|
||||
* Read CFFOLDER.
|
||||
*/
|
||||
hd->folder_array = (struct cffolder *)calloc(
|
||||
hd->folder_array = calloc(
|
||||
hd->folder_count, sizeof(struct cffolder));
|
||||
if (hd->folder_array == NULL)
|
||||
goto nomem;
|
||||
@@ -780,7 +780,7 @@ cab_read_header(struct archive_read *a)
|
||||
cab->cab_offset += skip;
|
||||
}
|
||||
/* Allocate memory for CFDATA */
|
||||
hd->file_array = (struct cffile *)calloc(
|
||||
hd->file_array = calloc(
|
||||
hd->file_count, sizeof(struct cffile));
|
||||
if (hd->file_array == NULL)
|
||||
goto nomem;
|
||||
@@ -1412,7 +1412,7 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail)
|
||||
if (cab->uncompressed_buffer == NULL) {
|
||||
cab->uncompressed_buffer_size = 0x8000;
|
||||
cab->uncompressed_buffer
|
||||
= (unsigned char *)malloc(cab->uncompressed_buffer_size);
|
||||
= malloc(cab->uncompressed_buffer_size);
|
||||
if (cab->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for CAB reader");
|
||||
@@ -1641,7 +1641,7 @@ cab_read_ahead_cfdata_lzx(struct archive_read *a, ssize_t *avail)
|
||||
if (cab->uncompressed_buffer == NULL) {
|
||||
cab->uncompressed_buffer_size = 0x8000;
|
||||
cab->uncompressed_buffer
|
||||
= (unsigned char *)malloc(cab->uncompressed_buffer_size);
|
||||
= malloc(cab->uncompressed_buffer_size);
|
||||
if (cab->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for CAB reader");
|
||||
|
||||
@@ -228,7 +228,7 @@ archive_read_support_format_cpio(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_cpio");
|
||||
|
||||
cpio = (struct cpio *)calloc(1, sizeof(*cpio));
|
||||
cpio = calloc(1, sizeof(*cpio));
|
||||
if (cpio == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -1088,7 +1088,7 @@ record_hardlink(struct archive_read *a,
|
||||
}
|
||||
}
|
||||
|
||||
le = (struct links_entry *)malloc(sizeof(struct links_entry));
|
||||
le = malloc(sizeof(struct links_entry));
|
||||
if (le == NULL) {
|
||||
archive_set_error(&a->archive,
|
||||
ENOMEM, "Out of memory adding file to list");
|
||||
|
||||
@@ -273,7 +273,7 @@ struct file_info {
|
||||
char re; /* Having RRIP "RE" extension. */
|
||||
char re_descendant;
|
||||
uint64_t cl_offset; /* Having RRIP "CL" extension. */
|
||||
int birthtime_is_set;
|
||||
int time_is_set; /* Bitmask indicating which times are known */
|
||||
time_t birthtime; /* File created time. */
|
||||
time_t mtime; /* File last modified time. */
|
||||
time_t atime; /* File last accessed time. */
|
||||
@@ -306,6 +306,11 @@ struct file_info {
|
||||
} rede_files;
|
||||
};
|
||||
|
||||
#define BIRTHTIME_IS_SET 1
|
||||
#define MTIME_IS_SET 2
|
||||
#define ATIME_IS_SET 4
|
||||
#define CTIME_IS_SET 8
|
||||
|
||||
struct heap_queue {
|
||||
struct file_info **files;
|
||||
int allocated;
|
||||
@@ -394,7 +399,9 @@ static void dump_isodirrec(FILE *, const unsigned char *isodirrec);
|
||||
#endif
|
||||
static time_t time_from_tm(struct tm *);
|
||||
static time_t isodate17(const unsigned char *);
|
||||
static int isodate17_valid(const unsigned char *);
|
||||
static time_t isodate7(const unsigned char *);
|
||||
static int isodate7_valid(const unsigned char *);
|
||||
static int isBootRecord(struct iso9660 *, const unsigned char *);
|
||||
static int isVolumePartition(struct iso9660 *, const unsigned char *);
|
||||
static int isVDSetTerminator(struct iso9660 *, const unsigned char *);
|
||||
@@ -456,7 +463,7 @@ archive_read_support_format_iso9660(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_iso9660");
|
||||
|
||||
iso9660 = (struct iso9660 *)calloc(1, sizeof(*iso9660));
|
||||
iso9660 = calloc(1, sizeof(*iso9660));
|
||||
if (iso9660 == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate iso9660 data");
|
||||
@@ -1351,13 +1358,22 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
|
||||
archive_entry_set_uid(entry, file->uid);
|
||||
archive_entry_set_gid(entry, file->gid);
|
||||
archive_entry_set_nlink(entry, file->nlinks);
|
||||
if (file->birthtime_is_set)
|
||||
if ((file->time_is_set & BIRTHTIME_IS_SET))
|
||||
archive_entry_set_birthtime(entry, file->birthtime, 0);
|
||||
else
|
||||
archive_entry_unset_birthtime(entry);
|
||||
archive_entry_set_mtime(entry, file->mtime, 0);
|
||||
archive_entry_set_ctime(entry, file->ctime, 0);
|
||||
archive_entry_set_atime(entry, file->atime, 0);
|
||||
if ((file->time_is_set & MTIME_IS_SET))
|
||||
archive_entry_set_mtime(entry, file->mtime, 0);
|
||||
else
|
||||
archive_entry_unset_mtime(entry);
|
||||
if ((file->time_is_set & CTIME_IS_SET))
|
||||
archive_entry_set_ctime(entry, file->ctime, 0);
|
||||
else
|
||||
archive_entry_unset_ctime(entry);
|
||||
if ((file->time_is_set & ATIME_IS_SET))
|
||||
archive_entry_set_atime(entry, file->atime, 0);
|
||||
else
|
||||
archive_entry_unset_atime(entry);
|
||||
/* N.B.: Rock Ridge supports 64-bit device numbers. */
|
||||
archive_entry_set_rdev(entry, (dev_t)file->rdev);
|
||||
archive_entry_set_size(entry, iso9660->entry_bytes_remaining);
|
||||
@@ -1889,7 +1905,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
|
||||
}
|
||||
|
||||
/* Create a new file entry and copy data from the ISO dir record. */
|
||||
file = (struct file_info *)calloc(1, sizeof(*file));
|
||||
file = calloc(1, sizeof(*file));
|
||||
if (file == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for file entry");
|
||||
@@ -1898,8 +1914,11 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
|
||||
file->parent = parent;
|
||||
file->offset = offset;
|
||||
file->size = fsize;
|
||||
file->mtime = isodate7(isodirrec + DR_date_offset);
|
||||
file->ctime = file->atime = file->mtime;
|
||||
if (isodate7_valid(isodirrec + DR_date_offset)) {
|
||||
file->time_is_set |= MTIME_IS_SET | ATIME_IS_SET | CTIME_IS_SET;
|
||||
file->mtime = isodate7(isodirrec + DR_date_offset);
|
||||
file->ctime = file->atime = file->mtime;
|
||||
}
|
||||
file->rede_files.first = NULL;
|
||||
file->rede_files.last = &(file->rede_files.first);
|
||||
|
||||
@@ -2573,51 +2592,73 @@ parse_rockridge_TF1(struct file_info *file, const unsigned char *data,
|
||||
/* Use 17-byte time format. */
|
||||
if ((flag & 1) && data_length >= 17) {
|
||||
/* Create time. */
|
||||
file->birthtime_is_set = 1;
|
||||
file->birthtime = isodate17(data);
|
||||
if (isodate17_valid(data)) {
|
||||
file->time_is_set |= BIRTHTIME_IS_SET;
|
||||
file->birthtime = isodate17(data);
|
||||
}
|
||||
data += 17;
|
||||
data_length -= 17;
|
||||
}
|
||||
if ((flag & 2) && data_length >= 17) {
|
||||
/* Modify time. */
|
||||
file->mtime = isodate17(data);
|
||||
if (isodate17_valid(data)) {
|
||||
file->time_is_set |= MTIME_IS_SET;
|
||||
file->mtime = isodate17(data);
|
||||
}
|
||||
data += 17;
|
||||
data_length -= 17;
|
||||
}
|
||||
if ((flag & 4) && data_length >= 17) {
|
||||
/* Access time. */
|
||||
file->atime = isodate17(data);
|
||||
if (isodate17_valid(data)) {
|
||||
file->time_is_set |= ATIME_IS_SET;
|
||||
file->atime = isodate17(data);
|
||||
}
|
||||
data += 17;
|
||||
data_length -= 17;
|
||||
}
|
||||
if ((flag & 8) && data_length >= 17) {
|
||||
/* Attribute change time. */
|
||||
file->ctime = isodate17(data);
|
||||
if (isodate17_valid(data)) {
|
||||
file->time_is_set |= CTIME_IS_SET;
|
||||
file->ctime = isodate17(data);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Use 7-byte time format. */
|
||||
if ((flag & 1) && data_length >= 7) {
|
||||
/* Create time. */
|
||||
file->birthtime_is_set = 1;
|
||||
file->birthtime = isodate7(data);
|
||||
if (isodate7_valid(data)) {
|
||||
file->time_is_set |= BIRTHTIME_IS_SET;
|
||||
file->birthtime = isodate7(data);
|
||||
}
|
||||
data += 7;
|
||||
data_length -= 7;
|
||||
}
|
||||
if ((flag & 2) && data_length >= 7) {
|
||||
/* Modify time. */
|
||||
file->mtime = isodate7(data);
|
||||
if (isodate7_valid(data)) {
|
||||
file->time_is_set |= MTIME_IS_SET;
|
||||
file->mtime = isodate7(data);
|
||||
}
|
||||
data += 7;
|
||||
data_length -= 7;
|
||||
}
|
||||
if ((flag & 4) && data_length >= 7) {
|
||||
/* Access time. */
|
||||
file->atime = isodate7(data);
|
||||
if (isodate7_valid(data)) {
|
||||
file->time_is_set |= ATIME_IS_SET;
|
||||
file->atime = isodate7(data);
|
||||
}
|
||||
data += 7;
|
||||
data_length -= 7;
|
||||
}
|
||||
if ((flag & 8) && data_length >= 7) {
|
||||
/* Attribute change time. */
|
||||
file->ctime = isodate7(data);
|
||||
if (isodate7_valid(data)) {
|
||||
file->time_is_set |= CTIME_IS_SET;
|
||||
file->ctime = isodate7(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3228,6 +3269,56 @@ isValid733Integer(const unsigned char *p)
|
||||
&& p[3] == p[4]);
|
||||
}
|
||||
|
||||
static int
|
||||
isodate7_valid(const unsigned char *v)
|
||||
{
|
||||
int year = v[0];
|
||||
int month = v[1];
|
||||
int day = v[2];
|
||||
int hour = v[3];
|
||||
int minute = v[4];
|
||||
int second = v[5];
|
||||
int gmt_off = (signed char)v[6];
|
||||
|
||||
/* ECMA-119 9.1.5 "If all seven values are zero, it shall mean
|
||||
* that the date is unspecified" */
|
||||
if (year == 0
|
||||
&& month == 0
|
||||
&& day == 0
|
||||
&& hour == 0
|
||||
&& minute == 0
|
||||
&& second == 0
|
||||
&& gmt_off == 0)
|
||||
return 0;
|
||||
/*
|
||||
* Sanity-test each individual field
|
||||
*/
|
||||
/* Year can have any value */
|
||||
/* Month must be 1-12 */
|
||||
if (month < 1 || month > 12)
|
||||
return 0;
|
||||
/* Day must be 1-31 */
|
||||
if (day < 1 || day > 31)
|
||||
return 0;
|
||||
/* Hour must be 0-23 */
|
||||
if (hour > 23)
|
||||
return 0;
|
||||
/* Minute must be 0-59 */
|
||||
if (minute > 59)
|
||||
return 0;
|
||||
/* second must be 0-59 according to ECMA-119 9.1.5 */
|
||||
/* BUT: we should probably allow for the time being in UTC, which
|
||||
allows up to 61 seconds in a minute in certain cases */
|
||||
if (second > 61)
|
||||
return 0;
|
||||
/* Offset from GMT must be -48 to +52 */
|
||||
if (gmt_off < -48 || gmt_off > +52)
|
||||
return 0;
|
||||
|
||||
/* All tests pass, this is OK */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static time_t
|
||||
isodate7(const unsigned char *v)
|
||||
{
|
||||
@@ -3254,6 +3345,67 @@ isodate7(const unsigned char *v)
|
||||
return (t);
|
||||
}
|
||||
|
||||
static int
|
||||
isodate17_valid(const unsigned char *v)
|
||||
{
|
||||
/* First 16 bytes are all ASCII digits */
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (v[i] < '0' || v[i] > '9')
|
||||
return 0;
|
||||
}
|
||||
|
||||
int year = (v[0] - '0') * 1000 + (v[1] - '0') * 100
|
||||
+ (v[2] - '0') * 10 + (v[3] - '0');
|
||||
int month = (v[4] - '0') * 10 + (v[5] - '0');
|
||||
int day = (v[6] - '0') * 10 + (v[7] - '0');
|
||||
int hour = (v[8] - '0') * 10 + (v[9] - '0');
|
||||
int minute = (v[10] - '0') * 10 + (v[11] - '0');
|
||||
int second = (v[12] - '0') * 10 + (v[13] - '0');
|
||||
int hundredths = (v[14] - '0') * 10 + (v[15] - '0');
|
||||
int gmt_off = (signed char)v[16];
|
||||
|
||||
if (year == 0 && month == 0 && day == 0
|
||||
&& hour == 0 && minute == 0 && second == 0
|
||||
&& hundredths == 0 && gmt_off == 0)
|
||||
return 0;
|
||||
/*
|
||||
* Sanity-test each individual field
|
||||
*/
|
||||
|
||||
/* Year must be 1900-2300 */
|
||||
/* (Not specified in ECMA-119, but these seem
|
||||
like reasonable limits. */
|
||||
if (year < 1900 || year > 2300)
|
||||
return 0;
|
||||
/* Month must be 1-12 */
|
||||
if (month < 1 || month > 12)
|
||||
return 0;
|
||||
/* Day must be 1-31 */
|
||||
if (day < 1 || day > 31)
|
||||
return 0;
|
||||
/* Hour must be 0-23 */
|
||||
if (hour > 23)
|
||||
return 0;
|
||||
/* Minute must be 0-59 */
|
||||
if (minute > 59)
|
||||
return 0;
|
||||
/* second must be 0-59 according to ECMA-119 9.1.5 */
|
||||
/* BUT: we should probably allow for the time being in UTC, which
|
||||
allows up to 61 seconds in a minute in certain cases */
|
||||
if (second > 61)
|
||||
return 0;
|
||||
/* Hundredths must be 0-99 */
|
||||
if (hundredths > 99)
|
||||
return 0;
|
||||
/* Offset from GMT must be -48 to +52 */
|
||||
if (gmt_off < -48 || gmt_off > +52)
|
||||
return 0;
|
||||
|
||||
/* All tests pass, this is OK */
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
static time_t
|
||||
isodate17(const unsigned char *v)
|
||||
{
|
||||
|
||||
@@ -265,7 +265,7 @@ archive_read_support_format_lha(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_lha");
|
||||
|
||||
lha = (struct lha *)calloc(1, sizeof(*lha));
|
||||
lha = calloc(1, sizeof(*lha));
|
||||
if (lha == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate lha data");
|
||||
|
||||
@@ -273,7 +273,7 @@ archive_read_support_format_mtree(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_mtree");
|
||||
|
||||
mtree = (struct mtree *)calloc(1, sizeof(*mtree));
|
||||
mtree = calloc(1, sizeof(*mtree));
|
||||
if (mtree == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate mtree data");
|
||||
|
||||
@@ -736,7 +736,7 @@ archive_read_support_format_rar(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
|
||||
"archive_read_support_format_rar");
|
||||
|
||||
rar = (struct rar *)calloc(1, sizeof(*rar));
|
||||
rar = calloc(1, sizeof(*rar));
|
||||
if (rar == NULL)
|
||||
{
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate rar data");
|
||||
@@ -1373,7 +1373,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
char unp_size[8];
|
||||
int ttime;
|
||||
struct archive_string_conv *sconv, *fn_sconv;
|
||||
unsigned long crc32_val;
|
||||
uint32_t crc32_computed, crc32_read;
|
||||
int ret = (ARCHIVE_OK), ret2;
|
||||
char *newptr;
|
||||
size_t newsize;
|
||||
@@ -1404,7 +1404,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
"Invalid header size");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
crc32_val = crc32(0, (const unsigned char *)p + 2, 7 - 2);
|
||||
crc32_computed = crc32(0, (const unsigned char *)p + 2, 7 - 2);
|
||||
__archive_read_consume(a, 7);
|
||||
|
||||
if (!(rar->file_flags & FHD_SOLID))
|
||||
@@ -1438,8 +1438,9 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
/* File Header CRC check. */
|
||||
crc32_val = crc32(crc32_val, h, (unsigned)(header_size - 7));
|
||||
if ((crc32_val & 0xffff) != archive_le16dec(rar_header.crc)) {
|
||||
crc32_computed = crc32(crc32_computed, h, (unsigned)(header_size - 7));
|
||||
crc32_read = archive_le16dec(rar_header.crc);
|
||||
if ((crc32_computed & 0xffff) != crc32_read) {
|
||||
#ifndef DONT_FAIL_ON_CRC_ERROR
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Header CRC error");
|
||||
@@ -2804,9 +2805,7 @@ make_table(struct archive_read *a, struct huffman_code *code)
|
||||
else
|
||||
code->tablesize = code->maxlength;
|
||||
|
||||
code->table =
|
||||
(struct huffman_table_entry *)calloc(1, sizeof(*code->table)
|
||||
* ((size_t)1 << code->tablesize));
|
||||
code->table = calloc(1U << code->tablesize, sizeof(*code->table));
|
||||
|
||||
return make_table_recurse(a, code, 0, code->table, 0, code->tablesize);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,11 @@ struct comp_state {
|
||||
or just a part of it. */
|
||||
uint8_t block_parsing_finished : 1;
|
||||
|
||||
signed int notused : 4;
|
||||
/* Flag used to indicate that a previous file using this buffer was
|
||||
encrypted, meaning no data in the buffer can be trusted */
|
||||
uint8_t data_encrypted : 1;
|
||||
|
||||
signed int notused : 3;
|
||||
|
||||
int flags; /* Uncompression flags. */
|
||||
int method; /* Uncompression algorithm method. */
|
||||
@@ -352,6 +356,12 @@ struct rar5 {
|
||||
/* The header of currently processed RARv5 block. Used in main
|
||||
* decompression logic loop. */
|
||||
struct compressed_block_header last_block_hdr;
|
||||
|
||||
/*
|
||||
* Custom field to denote that this archive contains encrypted entries
|
||||
*/
|
||||
int has_encrypted_entries;
|
||||
int headers_are_encrypted;
|
||||
};
|
||||
|
||||
/* Forward function declarations. */
|
||||
@@ -535,8 +545,7 @@ static void write_filter_data(struct rar5* rar, uint32_t offset,
|
||||
|
||||
/* Allocates a new filter descriptor and adds it to the filter array. */
|
||||
static struct filter_info* add_new_filter(struct rar5* rar) {
|
||||
struct filter_info* f =
|
||||
(struct filter_info*) calloc(1, sizeof(struct filter_info));
|
||||
struct filter_info* f = calloc(1, sizeof(*f));
|
||||
|
||||
if(!f) {
|
||||
return NULL;
|
||||
@@ -1597,6 +1606,7 @@ static int process_head_file_extra(struct archive_read* a,
|
||||
if(!read_var(a, &extra_field_id, &var_size))
|
||||
return ARCHIVE_EOF;
|
||||
|
||||
extra_field_size -= var_size;
|
||||
extra_data_size -= var_size;
|
||||
if(ARCHIVE_OK != consume(a, var_size)) {
|
||||
return ARCHIVE_EOF;
|
||||
@@ -1624,12 +1634,19 @@ static int process_head_file_extra(struct archive_read* a,
|
||||
&extra_data_size);
|
||||
break;
|
||||
case EX_CRYPT:
|
||||
/* Mark the entry as encrypted */
|
||||
archive_entry_set_is_data_encrypted(e, 1);
|
||||
rar->has_encrypted_entries = 1;
|
||||
rar->cstate.data_encrypted = 1;
|
||||
/* fallthrough */
|
||||
case EX_SUBDATA:
|
||||
/* fallthrough */
|
||||
default:
|
||||
/* Skip unsupported entry. */
|
||||
return consume(a, extra_data_size);
|
||||
extra_data_size -= extra_field_size;
|
||||
if (ARCHIVE_OK != consume(a, extra_field_size)) {
|
||||
return ARCHIVE_EOF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1747,9 +1764,11 @@ static int process_head_file(struct archive_read* a, struct rar5* rar,
|
||||
rar->file.solid = (compression_info & SOLID) > 0;
|
||||
|
||||
/* Archives which declare solid files without initializing the window
|
||||
* buffer first are invalid. */
|
||||
* buffer first are invalid, unless previous data was encrypted, in
|
||||
* which case we may never have had the chance */
|
||||
|
||||
if(rar->file.solid > 0 && rar->cstate.window_buf == NULL) {
|
||||
if(rar->file.solid > 0 && rar->cstate.data_encrypted == 0 &&
|
||||
rar->cstate.window_buf == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Declared solid file, but no window buffer "
|
||||
"initialized yet.");
|
||||
@@ -1778,6 +1797,8 @@ static int process_head_file(struct archive_read* a, struct rar5* rar,
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
rar->cstate.data_encrypted = 0; /* Reset for new buffer */
|
||||
|
||||
if(rar->cstate.window_size < (ssize_t) window_size &&
|
||||
rar->cstate.window_buf)
|
||||
@@ -1846,27 +1867,25 @@ static int process_head_file(struct archive_read* a, struct rar5* rar,
|
||||
|
||||
if (file_attr & (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM)) {
|
||||
char *fflags_text, *ptr;
|
||||
/* allocate for "rdonly,hidden,system," */
|
||||
fflags_text = malloc(22 * sizeof(char));
|
||||
/* allocate for ",rdonly,hidden,system" */
|
||||
fflags_text = malloc(22 * sizeof(*fflags_text));
|
||||
if (fflags_text != NULL) {
|
||||
ptr = fflags_text;
|
||||
if (file_attr & ATTR_READONLY) {
|
||||
strcpy(ptr, "rdonly,");
|
||||
strcpy(ptr, ",rdonly");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (file_attr & ATTR_HIDDEN) {
|
||||
strcpy(ptr, "hidden,");
|
||||
strcpy(ptr, ",hidden");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (file_attr & ATTR_SYSTEM) {
|
||||
strcpy(ptr, "system,");
|
||||
strcpy(ptr, ",system");
|
||||
ptr = ptr + 7;
|
||||
}
|
||||
if (ptr > fflags_text) {
|
||||
/* Delete trailing comma */
|
||||
*(ptr - 1) = '\0';
|
||||
archive_entry_copy_fflags_text(entry,
|
||||
fflags_text);
|
||||
fflags_text + 1);
|
||||
}
|
||||
free(fflags_text);
|
||||
}
|
||||
@@ -2282,6 +2301,10 @@ static int process_base_block(struct archive_read* a,
|
||||
ret = process_head_file(a, rar, entry, header_flags);
|
||||
return ret;
|
||||
case HEAD_CRYPT:
|
||||
archive_entry_set_is_metadata_encrypted(entry, 1);
|
||||
archive_entry_set_is_data_encrypted(entry, 1);
|
||||
rar->has_encrypted_entries = 1;
|
||||
rar->headers_are_encrypted = 1;
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Encryption is not supported");
|
||||
@@ -2426,6 +2449,14 @@ static int rar5_read_header(struct archive_read *a,
|
||||
struct rar5* rar = get_context(a);
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* It should be sufficient to call archive_read_next_header() for
|
||||
* a reader to determine if an entry is encrypted or not.
|
||||
*/
|
||||
if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
|
||||
rar->has_encrypted_entries = 0;
|
||||
}
|
||||
|
||||
if(rar->header_initialized == 0) {
|
||||
init_header(a);
|
||||
if ((ret = try_skip_sfx(a)) < ARCHIVE_WARN)
|
||||
@@ -4097,6 +4128,16 @@ static int rar5_read_data(struct archive_read *a, const void **buff,
|
||||
if (size)
|
||||
*size = 0;
|
||||
|
||||
if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
|
||||
rar->has_encrypted_entries = 0;
|
||||
}
|
||||
|
||||
if (rar->headers_are_encrypted || rar->cstate.data_encrypted) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Reading encrypted data is not currently supported");
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
if(rar->file.dir > 0) {
|
||||
/* Don't process any data if this file entry was declared
|
||||
* as a directory. This is needed, because entries marked as
|
||||
@@ -4148,11 +4189,14 @@ static int rar5_read_data(struct archive_read *a, const void **buff,
|
||||
static int rar5_read_data_skip(struct archive_read *a) {
|
||||
struct rar5* rar = get_context(a);
|
||||
|
||||
if(rar->main.solid) {
|
||||
if(rar->main.solid && (rar->cstate.data_encrypted == 0)) {
|
||||
/* In solid archives, instead of skipping the data, we need to
|
||||
* extract it, and dispose the result. The side effect of this
|
||||
* operation will be setting up the initial window buffer state
|
||||
* needed to be able to extract the selected file. */
|
||||
* needed to be able to extract the selected file. Note that
|
||||
* this is only possible when data withing this solid block is
|
||||
* not encrypted, in which case we'll skip and fail if the user
|
||||
* tries to read data. */
|
||||
|
||||
int ret;
|
||||
|
||||
@@ -4228,14 +4272,19 @@ static int rar5_cleanup(struct archive_read *a) {
|
||||
|
||||
static int rar5_capabilities(struct archive_read * a) {
|
||||
(void) a;
|
||||
return 0;
|
||||
return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
|
||||
| ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
|
||||
}
|
||||
|
||||
static int rar5_has_encrypted_entries(struct archive_read *_a) {
|
||||
(void) _a;
|
||||
if (_a && _a->format) {
|
||||
struct rar5 *rar = (struct rar5 *)_a->format->data;
|
||||
if (rar) {
|
||||
return rar->has_encrypted_entries;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unsupported for now. */
|
||||
return ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED;
|
||||
return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
|
||||
}
|
||||
|
||||
static int rar5_init(struct rar5* rar) {
|
||||
@@ -4244,6 +4293,12 @@ static int rar5_init(struct rar5* rar) {
|
||||
if(CDE_OK != cdeque_init(&rar->cstate.filters, 8192))
|
||||
return ARCHIVE_FATAL;
|
||||
|
||||
/*
|
||||
* Until enough data has been read, we cannot tell about
|
||||
* any encrypted entries yet.
|
||||
*/
|
||||
rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
|
||||
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ archive_read_support_format_raw(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_raw");
|
||||
|
||||
info = (struct raw_info *)calloc(1, sizeof(*info));
|
||||
info = calloc(1, sizeof(*info));
|
||||
if (info == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate raw_info data");
|
||||
|
||||
@@ -123,8 +123,6 @@ struct tar {
|
||||
struct archive_string entry_uname;
|
||||
struct archive_string entry_gname;
|
||||
struct archive_string entry_linkpath;
|
||||
struct archive_string longname;
|
||||
struct archive_string pax_global;
|
||||
struct archive_string line;
|
||||
int pax_hdrcharset_utf8;
|
||||
int64_t entry_bytes_remaining;
|
||||
@@ -258,7 +256,7 @@ archive_read_support_format_tar(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_tar");
|
||||
|
||||
tar = (struct tar *)calloc(1, sizeof(*tar));
|
||||
tar = calloc(1, sizeof(*tar));
|
||||
if (tar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate tar data");
|
||||
@@ -298,8 +296,6 @@ archive_read_format_tar_cleanup(struct archive_read *a)
|
||||
archive_string_free(&tar->entry_gname);
|
||||
archive_string_free(&tar->entry_linkpath);
|
||||
archive_string_free(&tar->line);
|
||||
archive_string_free(&tar->pax_global);
|
||||
archive_string_free(&tar->longname);
|
||||
archive_string_free(&tar->localname);
|
||||
free(tar);
|
||||
(a->format->data) = NULL;
|
||||
@@ -631,8 +627,6 @@ archive_read_format_tar_read_data(struct archive_read *a,
|
||||
}
|
||||
|
||||
*buff = __archive_read_ahead(a, 1, &bytes_read);
|
||||
if (bytes_read < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
if (*buff == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Truncated tar archive"
|
||||
@@ -727,6 +721,7 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
archive_string_empty(&(tar->entry_pathname));
|
||||
archive_string_empty(&(tar->entry_pathname_override));
|
||||
archive_string_empty(&(tar->entry_uname));
|
||||
archive_string_empty(&tar->entry_linkpath);
|
||||
|
||||
/* Ensure format is set. */
|
||||
if (a->archive.archive_format_name == NULL) {
|
||||
@@ -749,8 +744,6 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
|
||||
/* Read 512-byte header record */
|
||||
h = __archive_read_ahead(a, 512, &bytes);
|
||||
if (bytes < 0)
|
||||
return ((int)bytes);
|
||||
if (bytes == 0) { /* EOF at a block boundary. */
|
||||
if (eof_fatal) {
|
||||
/* We've read a special header already;
|
||||
@@ -763,7 +756,7 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
return (ARCHIVE_EOF);
|
||||
}
|
||||
}
|
||||
if (bytes < 512) { /* Short block at EOF; this is bad. */
|
||||
if (h == NULL) { /* Short block at EOF; this is bad. */
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated tar archive"
|
||||
@@ -1012,7 +1005,12 @@ checksum(struct archive_read *a, const void *h)
|
||||
if (sum == check)
|
||||
return (1);
|
||||
|
||||
#if DONT_FAIL_ON_CRC_ERROR
|
||||
/* Speed up fuzzing by pretending the checksum is always right. */
|
||||
return (1);
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1043,16 +1041,14 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
|
||||
int64_t type;
|
||||
char *acl, *p;
|
||||
|
||||
/*
|
||||
* read_body_to_string adds a NUL terminator, but we need a little
|
||||
* more to make sure that we don't overrun acl_text later.
|
||||
*/
|
||||
header = (const struct archive_entry_header_ustar *)h;
|
||||
size = (size_t)tar_atol(header->size, sizeof(header->size));
|
||||
archive_string_init(&acl_text);
|
||||
err = read_body_to_string(a, tar, &acl_text, h, unconsumed);
|
||||
if (err != ARCHIVE_OK)
|
||||
if (err != ARCHIVE_OK) {
|
||||
archive_string_free(&acl_text);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* TODO: Examine the first characters to see if this
|
||||
* is an AIX ACL descriptor. We'll likely never support
|
||||
@@ -1177,13 +1173,16 @@ header_gnu_longname(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
{
|
||||
int err;
|
||||
struct archive_string longname;
|
||||
|
||||
err = read_body_to_string(a, tar, &(tar->longname), h, unconsumed);
|
||||
if (err != ARCHIVE_OK)
|
||||
return (err);
|
||||
if (archive_entry_copy_pathname_l(entry, tar->longname.s,
|
||||
archive_strlen(&(tar->longname)), tar->sconv) != 0)
|
||||
err = set_conversion_failed_error(a, tar->sconv, "Pathname");
|
||||
archive_string_init(&longname);
|
||||
err = read_body_to_string(a, tar, &longname, h, unconsumed);
|
||||
if (err == ARCHIVE_OK) {
|
||||
if (archive_entry_copy_pathname_l(entry, longname.s,
|
||||
archive_strlen(&longname), tar->sconv) != 0)
|
||||
err = set_conversion_failed_error(a, tar->sconv, "Pathname");
|
||||
}
|
||||
archive_string_free(&longname);
|
||||
return (err);
|
||||
}
|
||||
|
||||
@@ -1520,9 +1519,17 @@ header_old_tar(struct archive_read *a, struct tar *tar,
|
||||
const struct archive_entry_header_ustar *header;
|
||||
int err = ARCHIVE_OK, err2;
|
||||
|
||||
/* Copy filename over (to ensure null termination). */
|
||||
/*
|
||||
* Copy filename over (to ensure null termination).
|
||||
* Skip if pathname was already set e.g. by header_gnu_longname()
|
||||
*/
|
||||
header = (const struct archive_entry_header_ustar *)h;
|
||||
if (archive_entry_copy_pathname_l(entry,
|
||||
|
||||
const char *existing_pathname = archive_entry_pathname(entry);
|
||||
const wchar_t *existing_wcs_pathname = archive_entry_pathname_w(entry);
|
||||
if ((existing_pathname == NULL || existing_pathname[0] == '\0')
|
||||
&& (existing_wcs_pathname == NULL || existing_wcs_pathname[0] == '\0') &&
|
||||
archive_entry_copy_pathname_l(entry,
|
||||
header->name, sizeof(header->name), tar->sconv) != 0) {
|
||||
err = set_conversion_failed_error(a, tar->sconv, "Pathname");
|
||||
if (err == ARCHIVE_FATAL)
|
||||
@@ -1630,6 +1637,9 @@ read_mac_metadata_blob(struct archive_read *a,
|
||||
tar_flush_unconsumed(a, unconsumed);
|
||||
data = __archive_read_ahead(a, msize, NULL);
|
||||
if (data == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading macOS metadata");
|
||||
*unconsumed = 0;
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
@@ -1817,10 +1827,7 @@ header_pax_extension(struct archive_read *a, struct tar *tar,
|
||||
to_read = ext_size;
|
||||
}
|
||||
p = __archive_read_ahead(a, to_read, &did_read);
|
||||
if (did_read < 0) {
|
||||
return ((int)did_read);
|
||||
}
|
||||
if (did_read == 0) { /* EOF */
|
||||
if (p == NULL) { /* EOF */
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated tar archive"
|
||||
" detected while reading pax attribute name");
|
||||
@@ -1895,6 +1902,7 @@ header_pax_extension(struct archive_read *a, struct tar *tar,
|
||||
name_length = p - name_start;
|
||||
p++; // Skip '='
|
||||
|
||||
// Save the name before we consume it
|
||||
archive_strncpy(&attr_name, name_start, name_length);
|
||||
|
||||
ext_size -= p - attr_start;
|
||||
@@ -1908,6 +1916,9 @@ header_pax_extension(struct archive_read *a, struct tar *tar,
|
||||
r = pax_attribute(a, tar, entry, attr_name.s, archive_strlen(&attr_name), value_length - 1, unconsumed);
|
||||
ext_size -= value_length - 1;
|
||||
|
||||
// Release the allocated attr_name (either here or before every return in this function)
|
||||
archive_string_free(&attr_name);
|
||||
|
||||
if (r < ARCHIVE_WARN) {
|
||||
*unconsumed += ext_size + ext_padding;
|
||||
return (r);
|
||||
@@ -1917,10 +1928,7 @@ header_pax_extension(struct archive_read *a, struct tar *tar,
|
||||
/* Consume the `\n` that follows the pax attribute value. */
|
||||
tar_flush_unconsumed(a, unconsumed);
|
||||
p = __archive_read_ahead(a, 1, &did_read);
|
||||
if (did_read < 0) {
|
||||
return ((int)did_read);
|
||||
}
|
||||
if (did_read == 0) {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated tar archive"
|
||||
" detected while completing pax attribute");
|
||||
@@ -2302,13 +2310,15 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
err = ARCHIVE_FAILED;
|
||||
} else {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p != NULL) {
|
||||
if (gnu_sparse_01_parse(a, tar, p, value_length) != ARCHIVE_OK) {
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
} else {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading GNU sparse data");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (gnu_sparse_01_parse(a, tar, p, value_length) != ARCHIVE_OK) {
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
}
|
||||
__archive_read_consume(a, value_length);
|
||||
return (err);
|
||||
@@ -2384,24 +2394,23 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
/* LIBARCHIVE.symlinktype */
|
||||
if (value_length < 16) {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p != NULL) {
|
||||
if (value_length == 4 && memcmp(p, "file", 4) == 0) {
|
||||
archive_entry_set_symlink_type(entry,
|
||||
AE_SYMLINK_TYPE_FILE);
|
||||
} else if (value_length == 3 && memcmp(p, "dir", 3) == 0) {
|
||||
archive_entry_set_symlink_type(entry,
|
||||
AE_SYMLINK_TYPE_DIRECTORY);
|
||||
} else {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Unrecognized symlink type");
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
} else {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated tar archive "
|
||||
"detected while reading `symlinktype` attribute");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (value_length == 4 && memcmp(p, "file", 4) == 0) {
|
||||
archive_entry_set_symlink_type(entry,
|
||||
AE_SYMLINK_TYPE_FILE);
|
||||
} else if (value_length == 3 && memcmp(p, "dir", 3) == 0) {
|
||||
archive_entry_set_symlink_type(entry,
|
||||
AE_SYMLINK_TYPE_DIRECTORY);
|
||||
} else {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Unrecognized symlink type");
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
} else {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"symlink type is very long"
|
||||
@@ -2419,8 +2428,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
err = ARCHIVE_WARN;
|
||||
} else {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p == NULL
|
||||
|| pax_attribute_LIBARCHIVE_xattr(entry, key, key_length, p, value_length)) {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading xattr information");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (pax_attribute_LIBARCHIVE_xattr(entry, key, key_length, p, value_length)) {
|
||||
/* TODO: Unable to parse xattr */
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
@@ -2443,8 +2457,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
err = ARCHIVE_WARN;
|
||||
} else {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p == NULL
|
||||
|| pax_attribute_RHT_security_selinux(entry, p, value_length)) {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading selinux data");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (pax_attribute_RHT_security_selinux(entry, p, value_length)) {
|
||||
/* TODO: Unable to parse xattr */
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
@@ -2491,13 +2510,15 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
else if (key_length == 6 && memcmp(key, "fflags", 6) == 0) {
|
||||
if (value_length < fflags_limit) {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p != NULL) {
|
||||
archive_entry_copy_fflags_text_len(entry, p, value_length);
|
||||
err = ARCHIVE_OK;
|
||||
} else {
|
||||
if (p == NULL) {
|
||||
/* Truncated archive */
|
||||
err = ARCHIVE_FATAL;
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading SCHILY.fflags");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
archive_entry_copy_fflags_text_len(entry, p, value_length);
|
||||
err = ARCHIVE_OK;
|
||||
} else {
|
||||
/* Overlong fflags field */
|
||||
err = ARCHIVE_WARN;
|
||||
@@ -2536,8 +2557,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
key += 6;
|
||||
if (value_length < xattr_limit) {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p == NULL
|
||||
|| pax_attribute_SCHILY_xattr(entry, key, key_length, p, value_length)) {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading SCHILY.xattr");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (pax_attribute_SCHILY_xattr(entry, key, key_length, p, value_length)) {
|
||||
/* TODO: Unable to parse xattr */
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
@@ -2560,16 +2586,18 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
/* SUN.holesdata */
|
||||
if (value_length < sparse_map_limit) {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p != NULL) {
|
||||
err = pax_attribute_SUN_holesdata(a, tar, entry, p, value_length);
|
||||
if (err < ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Parse error: SUN.holesdata");
|
||||
}
|
||||
} else {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Truncated archive"
|
||||
" detected while reading SUN.holesdata");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
err = pax_attribute_SUN_holesdata(a, tar, entry, p, value_length);
|
||||
if (err < ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Parse error: SUN.holesdata");
|
||||
}
|
||||
} else {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Unreasonably large sparse map: %d > %d",
|
||||
@@ -2621,26 +2649,25 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
if (key_length == 10 && memcmp(key, "hdrcharset", 10) == 0) {
|
||||
if (value_length < 64) {
|
||||
p = __archive_read_ahead(a, value_length, &bytes_read);
|
||||
if (p != NULL) {
|
||||
if (value_length == 6
|
||||
&& memcmp(p, "BINARY", 6) == 0) {
|
||||
/* Binary mode. */
|
||||
tar->pax_hdrcharset_utf8 = 0;
|
||||
err = ARCHIVE_OK;
|
||||
} else if (value_length == 23
|
||||
&& memcmp(p, "ISO-IR 10646 2000 UTF-8", 23) == 0) {
|
||||
tar->pax_hdrcharset_utf8 = 1;
|
||||
err = ARCHIVE_OK;
|
||||
} else {
|
||||
/* TODO: Unrecognized character set */
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
} else {
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated tar archive "
|
||||
"detected while reading hdrcharset attribute");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (value_length == 6
|
||||
&& memcmp(p, "BINARY", 6) == 0) {
|
||||
/* Binary mode. */
|
||||
tar->pax_hdrcharset_utf8 = 0;
|
||||
err = ARCHIVE_OK;
|
||||
} else if (value_length == 23
|
||||
&& memcmp(p, "ISO-IR 10646 2000 UTF-8", 23) == 0) {
|
||||
tar->pax_hdrcharset_utf8 = 1;
|
||||
err = ARCHIVE_OK;
|
||||
} else {
|
||||
/* TODO: Unrecognized character set */
|
||||
err = ARCHIVE_WARN;
|
||||
}
|
||||
} else {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"hdrcharset attribute is unreasonably large (%d bytes)",
|
||||
@@ -2908,7 +2935,7 @@ gnu_add_sparse_entry(struct archive_read *a, struct tar *tar,
|
||||
{
|
||||
struct sparse_block *p;
|
||||
|
||||
p = (struct sparse_block *)calloc(1, sizeof(*p));
|
||||
p = calloc(1, sizeof(*p));
|
||||
if (p == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Out of memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -2973,9 +3000,7 @@ gnu_sparse_old_read(struct archive_read *a, struct tar *tar,
|
||||
do {
|
||||
tar_flush_unconsumed(a, unconsumed);
|
||||
data = __archive_read_ahead(a, 512, &bytes_read);
|
||||
if (bytes_read < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
if (bytes_read < 512) {
|
||||
if (data == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated tar archive "
|
||||
"detected while reading sparse file data");
|
||||
@@ -3395,7 +3420,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
|
||||
tar_flush_unconsumed(a, unconsumed);
|
||||
|
||||
t = __archive_read_ahead(a, 1, &bytes_read);
|
||||
if (bytes_read <= 0)
|
||||
if (bytes_read <= 0 || t == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
s = t; /* Start of line? */
|
||||
p = memchr(t, '\n', bytes_read);
|
||||
@@ -3436,7 +3461,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
|
||||
}
|
||||
/* Read some more. */
|
||||
t = __archive_read_ahead(a, 1, &bytes_read);
|
||||
if (bytes_read <= 0)
|
||||
if (bytes_read <= 0 || t == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
s = t; /* Start of line? */
|
||||
p = memchr(t, '\n', bytes_read);
|
||||
@@ -3480,7 +3505,7 @@ base64_decode(const char *s, size_t len, size_t *out_len)
|
||||
|
||||
/* Allocate enough space to hold the entire output. */
|
||||
/* Note that we may not use all of this... */
|
||||
out = (char *)malloc(len - len / 4 + 1);
|
||||
out = malloc(len - len / 4 + 1);
|
||||
if (out == NULL) {
|
||||
*out_len = 0;
|
||||
return (NULL);
|
||||
@@ -3535,7 +3560,7 @@ url_decode(const char *in, size_t length)
|
||||
char *out, *d;
|
||||
const char *s;
|
||||
|
||||
out = (char *)malloc(length + 1);
|
||||
out = malloc(length + 1);
|
||||
if (out == NULL)
|
||||
return (NULL);
|
||||
for (s = in, d = out; length > 0 && *s != '\0'; ) {
|
||||
|
||||
@@ -450,7 +450,7 @@ archive_read_support_format_xar(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_xar");
|
||||
|
||||
xar = (struct xar *)calloc(1, sizeof(*xar));
|
||||
xar = calloc(1, sizeof(*xar));
|
||||
if (xar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate xar data");
|
||||
|
||||
@@ -1751,8 +1751,7 @@ zipx_xz_init(struct archive_read *a, struct zip *zip)
|
||||
free(zip->uncompressed_buffer);
|
||||
|
||||
zip->uncompressed_buffer_size = 256 * 1024;
|
||||
zip->uncompressed_buffer =
|
||||
(uint8_t*) malloc(zip->uncompressed_buffer_size);
|
||||
zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size);
|
||||
if (zip->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for xz decompression");
|
||||
@@ -1862,8 +1861,7 @@ zipx_lzma_alone_init(struct archive_read *a, struct zip *zip)
|
||||
|
||||
if(!zip->uncompressed_buffer) {
|
||||
zip->uncompressed_buffer_size = 256 * 1024;
|
||||
zip->uncompressed_buffer =
|
||||
(uint8_t*) malloc(zip->uncompressed_buffer_size);
|
||||
zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size);
|
||||
|
||||
if (zip->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
@@ -2167,8 +2165,7 @@ zipx_ppmd8_init(struct archive_read *a, struct zip *zip)
|
||||
free(zip->uncompressed_buffer);
|
||||
|
||||
zip->uncompressed_buffer_size = 256 * 1024;
|
||||
zip->uncompressed_buffer =
|
||||
(uint8_t*) malloc(zip->uncompressed_buffer_size);
|
||||
zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size);
|
||||
|
||||
if(zip->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
@@ -2291,8 +2288,7 @@ zipx_bzip2_init(struct archive_read *a, struct zip *zip)
|
||||
free(zip->uncompressed_buffer);
|
||||
|
||||
zip->uncompressed_buffer_size = 256 * 1024;
|
||||
zip->uncompressed_buffer =
|
||||
(uint8_t*) malloc(zip->uncompressed_buffer_size);
|
||||
zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size);
|
||||
if (zip->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for bzip2 decompression");
|
||||
@@ -2434,8 +2430,7 @@ zipx_zstd_init(struct archive_read *a, struct zip *zip)
|
||||
free(zip->uncompressed_buffer);
|
||||
|
||||
zip->uncompressed_buffer_size = ZSTD_DStreamOutSize();
|
||||
zip->uncompressed_buffer =
|
||||
(uint8_t*) malloc(zip->uncompressed_buffer_size);
|
||||
zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size);
|
||||
if (zip->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for Zstd decompression");
|
||||
@@ -2574,7 +2569,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
|
||||
if (zip->uncompressed_buffer == NULL) {
|
||||
zip->uncompressed_buffer_size = 256 * 1024;
|
||||
zip->uncompressed_buffer
|
||||
= (unsigned char *)malloc(zip->uncompressed_buffer_size);
|
||||
= malloc(zip->uncompressed_buffer_size);
|
||||
if (zip->uncompressed_buffer == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"No memory for ZIP decompression");
|
||||
@@ -3600,7 +3595,7 @@ archive_read_support_format_zip_streamable(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_zip");
|
||||
|
||||
zip = (struct zip *)calloc(1, sizeof(*zip));
|
||||
zip = calloc(1, sizeof(*zip));
|
||||
if (zip == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate zip data");
|
||||
@@ -4392,7 +4387,7 @@ archive_read_support_format_zip_seekable(struct archive *_a)
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable");
|
||||
|
||||
zip = (struct zip *)calloc(1, sizeof(*zip));
|
||||
zip = calloc(1, sizeof(*zip));
|
||||
if (zip == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate zip data");
|
||||
|
||||
@@ -313,7 +313,7 @@ archive_string_ensure(struct archive_string *as, size_t s)
|
||||
if (new_length < s)
|
||||
new_length = s;
|
||||
/* Now we can reallocate the buffer. */
|
||||
p = (char *)realloc(as->s, new_length);
|
||||
p = realloc(as->s, new_length);
|
||||
if (p == NULL) {
|
||||
/* On failure, wipe the string and return NULL. */
|
||||
archive_string_free(as);
|
||||
|
||||
@@ -651,8 +651,7 @@ archive_utility_string_sort_helper(char **strings, unsigned int n)
|
||||
if (strcmp(strings[i], pivot) < 0)
|
||||
{
|
||||
lesser_count++;
|
||||
tmp = (char **)realloc(lesser,
|
||||
lesser_count * sizeof(char *));
|
||||
tmp = realloc(lesser, lesser_count * sizeof(*tmp));
|
||||
if (!tmp) {
|
||||
free(greater);
|
||||
free(lesser);
|
||||
@@ -664,8 +663,7 @@ archive_utility_string_sort_helper(char **strings, unsigned int n)
|
||||
else
|
||||
{
|
||||
greater_count++;
|
||||
tmp = (char **)realloc(greater,
|
||||
greater_count * sizeof(char *));
|
||||
tmp = realloc(greater, greater_count * sizeof(*tmp));
|
||||
if (!tmp) {
|
||||
free(greater);
|
||||
free(lesser);
|
||||
|
||||
@@ -98,7 +98,7 @@ archive_write_new(void)
|
||||
struct archive_write *a;
|
||||
unsigned char *nulls;
|
||||
|
||||
a = (struct archive_write *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_WRITE_MAGIC;
|
||||
@@ -114,7 +114,7 @@ archive_write_new(void)
|
||||
|
||||
/* Initialize a block of nulls for padding purposes. */
|
||||
a->null_length = 1024;
|
||||
nulls = (unsigned char *)calloc(a->null_length, sizeof(unsigned char));
|
||||
nulls = calloc(a->null_length, sizeof(unsigned char));
|
||||
if (nulls == NULL) {
|
||||
free(a);
|
||||
return (NULL);
|
||||
@@ -367,8 +367,8 @@ archive_write_client_open(struct archive_write_filter *f)
|
||||
archive_write_get_bytes_in_last_block(f->archive);
|
||||
buffer_size = f->bytes_per_block;
|
||||
|
||||
state = (struct archive_none *)calloc(1, sizeof(*state));
|
||||
buffer = (char *)malloc(buffer_size);
|
||||
state = calloc(1, sizeof(*state));
|
||||
buffer = malloc(buffer_size);
|
||||
if (state == NULL || buffer == NULL) {
|
||||
free(state);
|
||||
free(buffer);
|
||||
|
||||
@@ -85,7 +85,7 @@ archive_write_add_filter_b64encode(struct archive *_a)
|
||||
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_write_add_filter_b64encode");
|
||||
|
||||
state = (struct private_b64encode *)calloc(1, sizeof(*state));
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for b64encode filter");
|
||||
|
||||
@@ -177,8 +177,7 @@ archive_compressor_bzip2_open(struct archive_write_filter *f)
|
||||
bs -= bs % bpb;
|
||||
}
|
||||
data->compressed_buffer_size = bs;
|
||||
data->compressed
|
||||
= (char *)malloc(data->compressed_buffer_size);
|
||||
data->compressed = malloc(data->compressed_buffer_size);
|
||||
if (data->compressed == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for compression buffer");
|
||||
|
||||
@@ -150,7 +150,7 @@ archive_compressor_compress_open(struct archive_write_filter *f)
|
||||
f->code = ARCHIVE_FILTER_COMPRESS;
|
||||
f->name = "compress";
|
||||
|
||||
state = (struct private_data *)calloc(1, sizeof(*state));
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for compression");
|
||||
|
||||
@@ -194,8 +194,7 @@ archive_compressor_gzip_open(struct archive_write_filter *f)
|
||||
bs -= bs % bpb;
|
||||
}
|
||||
data->compressed_buffer_size = bs;
|
||||
data->compressed
|
||||
= (unsigned char *)malloc(data->compressed_buffer_size);
|
||||
data->compressed = malloc(data->compressed_buffer_size);
|
||||
if (data->compressed == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for compression buffer");
|
||||
|
||||
@@ -74,7 +74,7 @@ archive_write_add_filter_uuencode(struct archive *_a)
|
||||
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_write_add_filter_uu");
|
||||
|
||||
state = (struct private_uuencode *)calloc(1, sizeof(*state));
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for uuencode filter");
|
||||
|
||||
@@ -319,8 +319,7 @@ archive_compressor_xz_open(struct archive_write_filter *f)
|
||||
bs -= bs % bpb;
|
||||
}
|
||||
data->compressed_buffer_size = bs;
|
||||
data->compressed
|
||||
= (unsigned char *)malloc(data->compressed_buffer_size);
|
||||
data->compressed = malloc(data->compressed_buffer_size);
|
||||
if (data->compressed == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for compression buffer");
|
||||
|
||||
@@ -372,8 +372,7 @@ archive_compressor_zstd_open(struct archive_write_filter *f)
|
||||
}
|
||||
data->out.size = bs;
|
||||
data->out.pos = 0;
|
||||
data->out.dst
|
||||
= (unsigned char *)malloc(data->out.size);
|
||||
data->out.dst = malloc(data->out.size);
|
||||
if (data->out.dst == NULL) {
|
||||
archive_set_error(f->archive, ENOMEM,
|
||||
"Can't allocate data for compression buffer");
|
||||
|
||||
@@ -1991,7 +1991,7 @@ archive_write_disk_new(void)
|
||||
{
|
||||
struct archive_write_disk *a;
|
||||
|
||||
a = (struct archive_write_disk *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC;
|
||||
@@ -2758,7 +2758,7 @@ new_fixup(struct archive_write_disk *a, const char *pathname)
|
||||
{
|
||||
struct fixup_entry *fe;
|
||||
|
||||
fe = (struct fixup_entry *)calloc(1, sizeof(struct fixup_entry));
|
||||
fe = calloc(1, sizeof(struct fixup_entry));
|
||||
if (fe == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate memory for a fixup");
|
||||
|
||||
@@ -1362,23 +1362,23 @@ archive_write_disk_set_user_lookup(struct archive *_a,
|
||||
int64_t
|
||||
archive_write_disk_gid(struct archive *_a, const char *name, la_int64_t id)
|
||||
{
|
||||
struct archive_write_disk *a = (struct archive_write_disk *)_a;
|
||||
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
|
||||
ARCHIVE_STATE_ANY, "archive_write_disk_gid");
|
||||
if (a->lookup_gid)
|
||||
return (a->lookup_gid)(a->lookup_gid_data, name, id);
|
||||
return (id);
|
||||
struct archive_write_disk *a = (struct archive_write_disk *)_a;
|
||||
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
|
||||
ARCHIVE_STATE_ANY, "archive_write_disk_gid");
|
||||
if (a->lookup_gid)
|
||||
return (a->lookup_gid)(a->lookup_gid_data, name, id);
|
||||
return (id);
|
||||
}
|
||||
|
||||
int64_t
|
||||
archive_write_disk_uid(struct archive *_a, const char *name, la_int64_t id)
|
||||
{
|
||||
struct archive_write_disk *a = (struct archive_write_disk *)_a;
|
||||
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
|
||||
ARCHIVE_STATE_ANY, "archive_write_disk_uid");
|
||||
if (a->lookup_uid)
|
||||
return (a->lookup_uid)(a->lookup_uid_data, name, id);
|
||||
return (id);
|
||||
struct archive_write_disk *a = (struct archive_write_disk *)_a;
|
||||
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
|
||||
ARCHIVE_STATE_ANY, "archive_write_disk_uid");
|
||||
if (a->lookup_uid)
|
||||
return (a->lookup_uid)(a->lookup_uid_data, name, id);
|
||||
return (id);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1389,7 +1389,7 @@ archive_write_disk_new(void)
|
||||
{
|
||||
struct archive_write_disk *a;
|
||||
|
||||
a = (struct archive_write_disk *)calloc(1, sizeof(*a));
|
||||
a = calloc(1, sizeof(*a));
|
||||
if (a == NULL)
|
||||
return (NULL);
|
||||
a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC;
|
||||
@@ -2079,7 +2079,7 @@ new_fixup(struct archive_write_disk *a, const wchar_t *pathname)
|
||||
{
|
||||
struct fixup_entry *fe;
|
||||
|
||||
fe = (struct fixup_entry *)calloc(1, sizeof(struct fixup_entry));
|
||||
fe = calloc(1, sizeof(struct fixup_entry));
|
||||
if (fe == NULL)
|
||||
return (NULL);
|
||||
fe->next = a->fixup_list;
|
||||
@@ -2243,13 +2243,15 @@ guidword(wchar_t *p, int n)
|
||||
* Canonicalize the pathname. In particular, this strips duplicate
|
||||
* '\' characters, '.' elements, and trailing '\'. It also raises an
|
||||
* error for an empty path, a trailing '..' or (if _SECURE_NODOTDOT is
|
||||
* set) any '..' in the path.
|
||||
* set) any '..' in the path or (if ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS)
|
||||
* if the path is absolute.
|
||||
*/
|
||||
static int
|
||||
cleanup_pathname(struct archive_write_disk *a, wchar_t *name)
|
||||
{
|
||||
wchar_t *dest, *src, *p, *top;
|
||||
wchar_t separator = L'\0';
|
||||
BOOL absolute_path = 0;
|
||||
|
||||
p = name;
|
||||
if (*p == L'\0') {
|
||||
@@ -2271,6 +2273,8 @@ cleanup_pathname(struct archive_write_disk *a, wchar_t *name)
|
||||
if (p[0] == L'\\' && p[1] == L'\\' &&
|
||||
(p[2] == L'.' || p[2] == L'?') && p[3] == L'\\')
|
||||
{
|
||||
absolute_path = 1;
|
||||
|
||||
/* A path begin with "\\?\UNC\" */
|
||||
if (p[2] == L'?' &&
|
||||
(p[4] == L'U' || p[4] == L'u') &&
|
||||
@@ -2318,9 +2322,10 @@ cleanup_pathname(struct archive_write_disk *a, wchar_t *name)
|
||||
return (ARCHIVE_FAILED);
|
||||
} else
|
||||
p += 4;
|
||||
/* Network drive path like "\\<server-name>\<share-name>\file" */
|
||||
} else if (p[0] == L'\\' && p[1] == L'\\') {
|
||||
p += 2;
|
||||
/* Network drive path like "\\<server-name>\<share-name>\file" */
|
||||
} else if (p[0] == L'\\' && p[1] == L'\\') {
|
||||
absolute_path = 1;
|
||||
p += 2;
|
||||
}
|
||||
|
||||
/* Skip leading drive letter from archives created
|
||||
@@ -2333,10 +2338,18 @@ cleanup_pathname(struct archive_write_disk *a, wchar_t *name)
|
||||
"Path is a drive name");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
absolute_path = 1;
|
||||
|
||||
if (p[2] == L'\\')
|
||||
p += 2;
|
||||
}
|
||||
|
||||
if (absolute_path && (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS)) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Path is absolute");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
top = dest = src = p;
|
||||
/* Rewrite the path name if its character is a unusable. */
|
||||
for (; *p != L'\0'; p++) {
|
||||
@@ -2829,7 +2842,7 @@ set_fflags(struct archive_write_disk *a)
|
||||
return (ARCHIVE_OK);
|
||||
return (set_fflags_platform(a->name, set, clear));
|
||||
|
||||
}
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ archive_write_open_fd(struct archive *a, int fd)
|
||||
{
|
||||
struct write_fd_data *mine;
|
||||
|
||||
mine = (struct write_fd_data *)malloc(sizeof(*mine));
|
||||
mine = malloc(sizeof(*mine));
|
||||
if (mine == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -59,7 +59,7 @@ archive_write_open_FILE(struct archive *a, FILE *f)
|
||||
{
|
||||
struct write_FILE_data *mine;
|
||||
|
||||
mine = (struct write_FILE_data *)malloc(sizeof(*mine));
|
||||
mine = malloc(sizeof(*mine));
|
||||
if (mine == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -98,7 +98,7 @@ open_filename(struct archive *a, int mbs_fn, const void *filename)
|
||||
struct write_file_data *mine;
|
||||
int r;
|
||||
|
||||
mine = (struct write_file_data *)calloc(1, sizeof(*mine));
|
||||
mine = calloc(1, sizeof(*mine));
|
||||
if (mine == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -52,7 +52,7 @@ archive_write_open_memory(struct archive *a, void *buff, size_t buffSize, size_t
|
||||
{
|
||||
struct write_memory_data *mine;
|
||||
|
||||
mine = (struct write_memory_data *)calloc(1, sizeof(*mine));
|
||||
mine = calloc(1, sizeof(*mine));
|
||||
if (mine == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -521,7 +521,7 @@ _7z_write_header(struct archive_write *a, struct archive_entry *entry)
|
||||
*/
|
||||
if (archive_entry_filetype(entry) == AE_IFLNK) {
|
||||
ssize_t bytes;
|
||||
const void *p = (const void *)archive_entry_symlink(entry);
|
||||
const void *p = (const void *)archive_entry_symlink_utf8(entry);
|
||||
bytes = compress_out(a, p, (size_t)file->size, ARCHIVE_Z_RUN);
|
||||
if (bytes < 0)
|
||||
return ((int)bytes);
|
||||
@@ -1563,8 +1563,18 @@ file_new(struct archive_write *a, struct archive_entry *entry,
|
||||
archive_entry_set_size(entry, 0);
|
||||
if (archive_entry_filetype(entry) == AE_IFDIR)
|
||||
file->dir = 1;
|
||||
else if (archive_entry_filetype(entry) == AE_IFLNK)
|
||||
file->size = strlen(archive_entry_symlink(entry));
|
||||
else if (archive_entry_filetype(entry) == AE_IFLNK) {
|
||||
const char* linkpath;
|
||||
linkpath = archive_entry_symlink_utf8(entry);
|
||||
if (linkpath == NULL) {
|
||||
free(file);
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"symlink path could not be converted to UTF-8");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
else
|
||||
file->size = strlen(linkpath);
|
||||
}
|
||||
if (archive_entry_mtime_is_set(entry)) {
|
||||
file->flg |= MTIME_IS_SET;
|
||||
file->times[MTIME].time = archive_entry_mtime(entry);
|
||||
|
||||
@@ -126,7 +126,7 @@ archive_write_set_format_ar(struct archive_write *a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
ar = (struct ar_w *)calloc(1, sizeof(*ar));
|
||||
ar = calloc(1, sizeof(*ar));
|
||||
if (ar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate ar data");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -246,7 +246,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
|
||||
se = (char *)malloc(strlen(filename) + 3);
|
||||
se = malloc(strlen(filename) + 3);
|
||||
if (se == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate filename buffer");
|
||||
@@ -379,7 +379,7 @@ archive_write_ar_data(struct archive_write *a, const void *buff, size_t s)
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
|
||||
ar->strtab = (char *)malloc(s + 1);
|
||||
ar->strtab = malloc(s + 1);
|
||||
if (ar->strtab == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate strtab buffer");
|
||||
|
||||
@@ -185,7 +185,7 @@ archive_write_set_format_cpio_binary(struct archive *_a, int format)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
cpio = (struct cpio *)calloc(1, sizeof(*cpio));
|
||||
cpio = calloc(1, sizeof(*cpio));
|
||||
if (cpio == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -116,7 +116,7 @@ archive_write_set_format_cpio_newc(struct archive *_a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
cpio = (struct cpio *)calloc(1, sizeof(*cpio));
|
||||
cpio = calloc(1, sizeof(*cpio));
|
||||
if (cpio == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -110,7 +110,7 @@ archive_write_set_format_cpio_odc(struct archive *_a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
cpio = (struct cpio *)calloc(1, sizeof(*cpio));
|
||||
cpio = calloc(1, sizeof(*cpio));
|
||||
if (cpio == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -174,7 +174,7 @@ archive_write_set_format_gnutar(struct archive *_a)
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
struct gnutar *gnutar;
|
||||
|
||||
gnutar = (struct gnutar *)calloc(1, sizeof(*gnutar));
|
||||
gnutar = calloc(1, sizeof(*gnutar));
|
||||
if (gnutar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate gnutar data");
|
||||
|
||||
@@ -138,7 +138,7 @@ archive_write_set_format_pax(struct archive *_a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
pax = (struct pax *)calloc(1, sizeof(*pax));
|
||||
pax = calloc(1, sizeof(*pax));
|
||||
if (pax == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate pax data");
|
||||
@@ -1944,7 +1944,7 @@ url_encode(const char *in)
|
||||
}
|
||||
}
|
||||
|
||||
out = (char *)malloc(out_len + 1);
|
||||
out = malloc(out_len + 1);
|
||||
if (out == NULL)
|
||||
return (NULL);
|
||||
|
||||
@@ -1982,7 +1982,7 @@ base64_encode(const char *s, size_t len)
|
||||
char *d, *out;
|
||||
|
||||
/* 3 bytes becomes 4 chars, but round up and allow for trailing NUL */
|
||||
out = (char *)malloc((len * 4 + 2) / 3 + 1);
|
||||
out = malloc((len * 4 + 2) / 3 + 1);
|
||||
if (out == NULL)
|
||||
return (NULL);
|
||||
d = out;
|
||||
@@ -2037,7 +2037,7 @@ _sparse_list_add_block(struct pax *pax, int64_t offset, int64_t length,
|
||||
{
|
||||
struct sparse_block *sb;
|
||||
|
||||
sb = (struct sparse_block *)malloc(sizeof(*sb));
|
||||
sb = malloc(sizeof(*sb));
|
||||
if (sb == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
sb->next = NULL;
|
||||
|
||||
@@ -58,7 +58,7 @@ archive_write_set_format_raw(struct archive *_a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
raw = (struct raw *)calloc(1, sizeof(*raw));
|
||||
raw = calloc(1, sizeof(*raw));
|
||||
if (raw == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate raw data");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -113,7 +113,7 @@ archive_write_set_format_shar(struct archive *_a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
shar = (struct shar *)calloc(1, sizeof(*shar));
|
||||
shar = calloc(1, sizeof(*shar));
|
||||
if (shar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM, "Can't allocate shar data");
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
@@ -183,7 +183,7 @@ archive_write_set_format_ustar(struct archive *_a)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
ustar = (struct ustar *)calloc(1, sizeof(*ustar));
|
||||
ustar = calloc(1, sizeof(*ustar));
|
||||
if (ustar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate ustar data");
|
||||
|
||||
@@ -160,7 +160,7 @@ archive_write_set_format_v7tar(struct archive *_a)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
v7tar = (struct v7tar *)calloc(1, sizeof(*v7tar));
|
||||
v7tar = calloc(1, sizeof(*v7tar));
|
||||
if (v7tar == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate v7tar data");
|
||||
|
||||
@@ -456,7 +456,7 @@ archive_write_set_format_zip(struct archive *_a)
|
||||
if (a->format_free != NULL)
|
||||
(a->format_free)(a);
|
||||
|
||||
zip = (struct zip *) calloc(1, sizeof(*zip));
|
||||
zip = calloc(1, sizeof(*zip));
|
||||
if (zip == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate zip data");
|
||||
|
||||
Reference in New Issue
Block a user