Skip to content

Commit 10f4a6c

Browse files
committed
MFC r368207,368607:
MFC r368207: Update libarchive to 3.5.0 Relevant vendor changes: Issue freebsd#1258: add archive_read_support_filter_by_code() PR freebsd#1347: mtree digest reader support Issue freebsd#1381: skip hardlinks pointing to itself on extraction PR freebsd#1387: fix writing of cpio archives with hardlinks without file type PR freebsd#1388: fix rdev field in cpio format for device nodes PR freebsd#1389: completed support for UTF-8 encoding conversion PR freebsd#1405: more formats in archive_read_support_format_by_code() PR freebsd#1408: fix uninitialized size in rar5_read_data PR freebsd#1409: system extended attribute support PR freebsd#1435: support for decompression of symbolic links in zipx archives Issue freebsd#1456: memory leak after unsuccessful archive_write_open_filename MFC r368607: Sync libarchive with vendor. Vendor changes: Issue freebsd#1461: Unbreak build without lzma Issue freebsd#1462: warc reader: Fix build with gcc11 Issue freebsd#1463: Fix code compatibility in test_archive_read_support.c Issue freebsd#1464: Use built-in strnlen on platforms where not available Issue freebsd#1465: warc reader: fix undefined behaviour in deconst() function
1 parent e0707d5 commit 10f4a6c

File tree

65 files changed

+1301
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1301
-189
lines changed

contrib/libarchive/COPYING

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ the actual statements in the files are controlling.
1515
* The following source files are also subject in whole or in part to
1616
a 3-clause UC Regents copyright; please read the individual source
1717
files for details:
18-
libarchive/archive_entry.c
1918
libarchive/archive_read_support_filter_compress.c
2019
libarchive/archive_write_add_filter_compress.c
2120
libarchive/mtree.5

contrib/libarchive/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Dec 01, 2020: libarchive 3.5.0 released
2+
3+
Oct 14, 2020: Support for system extended attributes
4+
15
May 20, 2020: libarchive 3.4.3 released
26

37
Apr 30, 2020: Support for pzstd compressed files

contrib/libarchive/libarchive/archive.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
3737
*/
3838
/* Note: Compiler will complain if this does not match archive_entry.h! */
39-
#define ARCHIVE_VERSION_NUMBER 3004003
39+
#define ARCHIVE_VERSION_NUMBER 3005000
4040

4141
#include <sys/stat.h>
4242
#include <stddef.h> /* for wchar_t */
@@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void);
155155
/*
156156
* Textual name/version of the library, useful for version displays.
157157
*/
158-
#define ARCHIVE_VERSION_ONLY_STRING "3.4.3"
158+
#define ARCHIVE_VERSION_ONLY_STRING "3.5.0"
159159
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
160160
__LA_DECL const char * archive_version_string(void);
161161

@@ -246,6 +246,8 @@ typedef int archive_open_callback(struct archive *, void *_client_data);
246246

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

249+
typedef int archive_free_callback(struct archive *, void *_client_data);
250+
249251
/* Switches from one client data object to the next/prev client data object.
250252
* This is useful for reading from different data blocks such as a set of files
251253
* that make up one large file.
@@ -418,6 +420,7 @@ __LA_DECL int archive_read_support_compression_xz(struct archive *)
418420
#endif
419421

420422
__LA_DECL int archive_read_support_filter_all(struct archive *);
423+
__LA_DECL int archive_read_support_filter_by_code(struct archive *, int);
421424
__LA_DECL int archive_read_support_filter_bzip2(struct archive *);
422425
__LA_DECL int archive_read_support_filter_compress(struct archive *);
423426
__LA_DECL int archive_read_support_filter_gzip(struct archive *);
@@ -817,9 +820,13 @@ __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const ch
817820
__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
818821
__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
819822
__LA_DECL int archive_write_zip_set_compression_store(struct archive *);
823+
/* Deprecated; use archive_write_open2 instead */
820824
__LA_DECL int archive_write_open(struct archive *, void *,
821825
archive_open_callback *, archive_write_callback *,
822826
archive_close_callback *);
827+
__LA_DECL int archive_write_open2(struct archive *, void *,
828+
archive_open_callback *, archive_write_callback *,
829+
archive_close_callback *, archive_free_callback *);
823830
__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
824831
__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
825832
__LA_DECL int archive_write_open_filename_w(struct archive *,

contrib/libarchive/libarchive/archive_acl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ archive_acl_text_len(struct archive_acl *acl, int want_type, int flags,
595595
else
596596
length += sizeof(uid_t) * 3 + 1;
597597
} else {
598-
r = archive_mstring_get_mbs_l(&ap->name, &name,
598+
r = archive_mstring_get_mbs_l(a, &ap->name, &name,
599599
&len, sc);
600600
if (r != 0)
601601
return (0);
@@ -966,7 +966,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags,
966966
else
967967
prefix = NULL;
968968
r = archive_mstring_get_mbs_l(
969-
&ap->name, &name, &len, sc);
969+
NULL, &ap->name, &name, &len, sc);
970970
if (r != 0)
971971
return (NULL);
972972
if (count > 0)
@@ -1398,14 +1398,14 @@ isint_w(const wchar_t *start, const wchar_t *end, int *result)
13981398
if (start >= end)
13991399
return (0);
14001400
while (start < end) {
1401-
if (*start < '0' || *start > '9')
1401+
if (*start < L'0' || *start > L'9')
14021402
return (0);
14031403
if (n > (INT_MAX / 10) ||
1404-
(n == INT_MAX / 10 && (*start - '0') > INT_MAX % 10)) {
1404+
(n == INT_MAX / 10 && (*start - L'0') > INT_MAX % 10)) {
14051405
n = INT_MAX;
14061406
} else {
14071407
n *= 10;
1408-
n += *start - '0';
1408+
n += *start - L'0';
14091409
}
14101410
start++;
14111411
}

contrib/libarchive/libarchive/archive_check_magic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ errmsg(const char *m)
5454
ssize_t written;
5555

5656
while (s > 0) {
57-
written = write(2, m, strlen(m));
57+
written = write(2, m, s);
5858
if (written <= 0)
5959
return;
6060
m += written;

contrib/libarchive/libarchive/archive_cryptor.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,31 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
347347
static int
348348
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
349349
{
350+
#if NETTLE_VERSION_MAJOR < 3
350351
aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
351352
aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
353+
#else
354+
switch(ctx->key_len) {
355+
case AES128_KEY_SIZE:
356+
aes128_set_encrypt_key(&ctx->ctx.c128, ctx->key);
357+
aes128_encrypt(&ctx->ctx.c128, AES_BLOCK_SIZE, ctx->encr_buf,
358+
ctx->nonce);
359+
break;
360+
case AES192_KEY_SIZE:
361+
aes192_set_encrypt_key(&ctx->ctx.c192, ctx->key);
362+
aes192_encrypt(&ctx->ctx.c192, AES_BLOCK_SIZE, ctx->encr_buf,
363+
ctx->nonce);
364+
break;
365+
case AES256_KEY_SIZE:
366+
aes256_set_encrypt_key(&ctx->ctx.c256, ctx->key);
367+
aes256_encrypt(&ctx->ctx.c256, AES_BLOCK_SIZE, ctx->encr_buf,
368+
ctx->nonce);
369+
break;
370+
default:
371+
return -1;
372+
break;
373+
}
374+
#endif
352375
return 0;
353376
}
354377

contrib/libarchive/libarchive/archive_cryptor_private.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,18 @@ typedef struct {
104104
#include <nettle/pbkdf2.h>
105105
#endif
106106
#include <nettle/aes.h>
107+
#include <nettle/version.h>
107108

108109
typedef struct {
110+
#if NETTLE_VERSION_MAJOR < 3
109111
struct aes_ctx ctx;
112+
#else
113+
union {
114+
struct aes128_ctx c128;
115+
struct aes192_ctx c192;
116+
struct aes256_ctx c256;
117+
} ctx;
118+
#endif
110119
uint8_t key[AES_MAX_KEY_SIZE];
111120
unsigned key_len;
112121
uint8_t nonce[AES_BLOCK_SIZE];

contrib/libarchive/libarchive/archive_digest_private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#ifndef __LIBARCHIVE_BUILD
3131
#error This header is only to be used internally to libarchive.
3232
#endif
33+
#ifndef __LIBARCHIVE_CONFIG_H_INCLUDED
34+
#error "Should have include config.h first!"
35+
#endif
36+
3337
/*
3438
* Crypto support in various Operating Systems:
3539
*

contrib/libarchive/libarchive/archive_entry.c

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ archive_entry_clone(struct archive_entry *entry)
208208

209209
/* Copy encryption status */
210210
entry2->encryption = entry->encryption;
211+
212+
/* Copy digests */
213+
#define copy_digest(_e2, _e, _t) \
214+
memcpy(_e2->digest._t, _e->digest._t, sizeof(_e2->digest._t))
215+
216+
copy_digest(entry2, entry, md5);
217+
copy_digest(entry2, entry, rmd160);
218+
copy_digest(entry2, entry, sha1);
219+
copy_digest(entry2, entry, sha256);
220+
copy_digest(entry2, entry, sha384);
221+
copy_digest(entry2, entry, sha512);
222+
223+
#undef copy_digest
211224

212225
/* Copy ACL data over. */
213226
archive_acl_copy(&entry2->acl, &entry->acl);
@@ -450,7 +463,7 @@ int
450463
_archive_entry_gname_l(struct archive_entry *entry,
451464
const char **p, size_t *len, struct archive_string_conv *sc)
452465
{
453-
return (archive_mstring_get_mbs_l(&entry->ae_gname, p, len, sc));
466+
return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_gname, p, len, sc));
454467
}
455468

456469
const char *
@@ -504,7 +517,7 @@ _archive_entry_hardlink_l(struct archive_entry *entry,
504517
*len = 0;
505518
return (0);
506519
}
507-
return (archive_mstring_get_mbs_l(&entry->ae_hardlink, p, len, sc));
520+
return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_hardlink, p, len, sc));
508521
}
509522

510523
la_int64_t
@@ -595,7 +608,7 @@ int
595608
_archive_entry_pathname_l(struct archive_entry *entry,
596609
const char **p, size_t *len, struct archive_string_conv *sc)
597610
{
598-
return (archive_mstring_get_mbs_l(&entry->ae_pathname, p, len, sc));
611+
return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_pathname, p, len, sc));
599612
}
600613

601614
__LA_MODE_T
@@ -723,7 +736,7 @@ _archive_entry_symlink_l(struct archive_entry *entry,
723736
*len = 0;
724737
return (0);
725738
}
726-
return (archive_mstring_get_mbs_l( &entry->ae_symlink, p, len, sc));
739+
return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_symlink, p, len, sc));
727740
}
728741

729742
la_int64_t
@@ -769,7 +782,7 @@ int
769782
_archive_entry_uname_l(struct archive_entry *entry,
770783
const char **p, size_t *len, struct archive_string_conv *sc)
771784
{
772-
return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
785+
return (archive_mstring_get_mbs_l(entry->archive, &entry->ae_uname, p, len, sc));
773786
}
774787

775788
int
@@ -1416,6 +1429,62 @@ archive_entry_copy_mac_metadata(struct archive_entry *entry,
14161429
}
14171430
}
14181431

1432+
/* Digest handling */
1433+
const unsigned char *
1434+
archive_entry_digest(struct archive_entry *entry, int type)
1435+
{
1436+
switch (type) {
1437+
case ARCHIVE_ENTRY_DIGEST_MD5:
1438+
return entry->digest.md5;
1439+
case ARCHIVE_ENTRY_DIGEST_RMD160:
1440+
return entry->digest.rmd160;
1441+
case ARCHIVE_ENTRY_DIGEST_SHA1:
1442+
return entry->digest.sha1;
1443+
case ARCHIVE_ENTRY_DIGEST_SHA256:
1444+
return entry->digest.sha256;
1445+
case ARCHIVE_ENTRY_DIGEST_SHA384:
1446+
return entry->digest.sha384;
1447+
case ARCHIVE_ENTRY_DIGEST_SHA512:
1448+
return entry->digest.sha512;
1449+
default:
1450+
return NULL;
1451+
}
1452+
}
1453+
1454+
int
1455+
archive_entry_set_digest(struct archive_entry *entry, int type,
1456+
const unsigned char *digest)
1457+
{
1458+
#define copy_digest(_e, _t, _d)\
1459+
memcpy(_e->digest._t, _d, sizeof(_e->digest._t))
1460+
1461+
switch (type) {
1462+
case ARCHIVE_ENTRY_DIGEST_MD5:
1463+
copy_digest(entry, md5, digest);
1464+
break;
1465+
case ARCHIVE_ENTRY_DIGEST_RMD160:
1466+
copy_digest(entry, rmd160, digest);
1467+
break;
1468+
case ARCHIVE_ENTRY_DIGEST_SHA1:
1469+
copy_digest(entry, sha1, digest);
1470+
break;
1471+
case ARCHIVE_ENTRY_DIGEST_SHA256:
1472+
copy_digest(entry, sha256, digest);
1473+
break;
1474+
case ARCHIVE_ENTRY_DIGEST_SHA384:
1475+
copy_digest(entry, sha384, digest);
1476+
break;
1477+
case ARCHIVE_ENTRY_DIGEST_SHA512:
1478+
copy_digest(entry, sha512, digest);
1479+
break;
1480+
default:
1481+
return ARCHIVE_WARN;
1482+
}
1483+
1484+
return ARCHIVE_OK;
1485+
#undef copy_digest
1486+
}
1487+
14191488
/*
14201489
* ACL management. The following would, of course, be a lot simpler
14211490
* if: 1) the last draft of POSIX.1e were a really thorough and

contrib/libarchive/libarchive/archive_entry.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define ARCHIVE_ENTRY_H_INCLUDED
3131

3232
/* Note: Compiler will complain if this does not match archive.h! */
33-
#define ARCHIVE_VERSION_NUMBER 3004003
33+
#define ARCHIVE_VERSION_NUMBER 3005000
3434

3535
/*
3636
* Note: archive_entry.h is for use outside of libarchive; the
@@ -396,6 +396,19 @@ __LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat
396396
__LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
397397
__LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
398398

399+
/*
400+
* Digest routine. This is used to query the raw hex digest for the
401+
* given entry. The type of digest is provided as an argument.
402+
*/
403+
#define ARCHIVE_ENTRY_DIGEST_MD5 0x00000001
404+
#define ARCHIVE_ENTRY_DIGEST_RMD160 0x00000002
405+
#define ARCHIVE_ENTRY_DIGEST_SHA1 0x00000003
406+
#define ARCHIVE_ENTRY_DIGEST_SHA256 0x00000004
407+
#define ARCHIVE_ENTRY_DIGEST_SHA384 0x00000005
408+
#define ARCHIVE_ENTRY_DIGEST_SHA512 0x00000006
409+
410+
__LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);
411+
399412
/*
400413
* ACL routines. This used to simply store and return text-format ACL
401414
* strings, but that proved insufficient for a number of reasons:

0 commit comments

Comments
 (0)