View | Details | Raw Unified | Return to bug 278588
Collapse All | Expand All

(-)b/contrib/libarchive/NEWS (+2 lines)
Lines 1-3 Link Here
1
Apr 26, 2024: libarchive 3.7.4 released
2
1
Apr 08, 2024: libarchive 3.7.3 released
3
Apr 08, 2024: libarchive 3.7.3 released
2
4
3
Sep 12, 2023: libarchive 3.7.2 released
5
Sep 12, 2023: libarchive 3.7.2 released
(-)b/contrib/libarchive/README.md (-1 / +1 lines)
Lines 201-207 questions we are asked about libarchive: Link Here
201
  In case other thread calls the same function in parallel, it might
201
  In case other thread calls the same function in parallel, it might
202
  get interrupted by it and cause the executable to use umask=0 for the
202
  get interrupted by it and cause the executable to use umask=0 for the
203
  remaining execution.
203
  remaining execution.
204
  This will then lead to implicitely created directories to have 777
204
  This will then lead to implicitly created directories to have 777
205
  permissions without sticky bit.
205
  permissions without sticky bit.
206
206
207
* In particular, libarchive's modules to read or write a directory
207
* In particular, libarchive's modules to read or write a directory
(-)b/contrib/libarchive/cat/cmdline.c (-5 / +11 lines)
Lines 114-125 bsdcat_getopt(struct bsdcat *bsdcat) Link Here
114
	enum { state_start = 0, state_old_tar, state_next_word,
114
	enum { state_start = 0, state_old_tar, state_next_word,
115
	       state_short, state_long };
115
	       state_short, state_long };
116
116
117
	const struct bsdcat_option *popt, *match = NULL, *match2 = NULL;
117
	const struct bsdcat_option *popt, *match, *match2;
118
	const char *p, *long_prefix = "--";
118
	const char *p, *long_prefix;
119
	size_t optlength;
119
	size_t optlength;
120
	int opt = '?';
120
	int opt;
121
	int required = 0;
121
	int required;
122
122
123
again:
124
	match = NULL;
125
	match2 = NULL;
126
	long_prefix = "--";
127
	opt = '?';
128
	required = 0;
123
	bsdcat->argument = NULL;
129
	bsdcat->argument = NULL;
124
130
125
	/* First time through, initialize everything. */
131
	/* First time through, initialize everything. */
Lines 172-178 bsdcat_getopt(struct bsdcat *bsdcat) Link Here
172
		if (opt == '\0') {
178
		if (opt == '\0') {
173
			/* End of this group; recurse to get next option. */
179
			/* End of this group; recurse to get next option. */
174
			bsdcat->getopt_state = state_next_word;
180
			bsdcat->getopt_state = state_next_word;
175
			return bsdcat_getopt(bsdcat);
181
			goto again;
176
		}
182
		}
177
183
178
		/* Does this option take an argument? */
184
		/* Does this option take an argument? */
(-)b/contrib/libarchive/cpio/cmdline.c (-5 / +11 lines)
Lines 114-125 cpio_getopt(struct cpio *cpio) Link Here
114
	static int state = state_start;
114
	static int state = state_start;
115
	static char *opt_word;
115
	static char *opt_word;
116
116
117
	const struct option *popt, *match = NULL, *match2 = NULL;
117
	const struct option *popt, *match, *match2;
118
	const char *p, *long_prefix = "--";
118
	const char *p, *long_prefix;
119
	size_t optlength;
119
	size_t optlength;
120
	int opt = '?';
120
	int opt;
121
	int required = 0;
121
	int required;
122
122
123
again:
124
	match = NULL;
125
	match2 = NULL;
126
	long_prefix = "--";
127
	opt = '?';
128
	required = 0;
123
	cpio->argument = NULL;
129
	cpio->argument = NULL;
124
130
125
	/* First time through, initialize everything. */
131
	/* First time through, initialize everything. */
Lines 169-175 cpio_getopt(struct cpio *cpio) Link Here
169
		if (opt == '\0') {
175
		if (opt == '\0') {
170
			/* End of this group; recurse to get next option. */
176
			/* End of this group; recurse to get next option. */
171
			state = state_next_word;
177
			state = state_next_word;
172
			return cpio_getopt(cpio);
178
			goto again;
173
		}
179
		}
174
180
175
		/* Does this option take an argument? */
181
		/* Does this option take an argument? */
(-)b/contrib/libarchive/libarchive/archive.h (-3 / +3 lines)
Lines 34-40 Link Here
34
 * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
34
 * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
35
 */
35
 */
36
/* Note: Compiler will complain if this does not match archive_entry.h! */
36
/* Note: Compiler will complain if this does not match archive_entry.h! */
37
#define	ARCHIVE_VERSION_NUMBER 3007003
37
#define	ARCHIVE_VERSION_NUMBER 3007004
38
38
39
#include <sys/stat.h>
39
#include <sys/stat.h>
40
#include <stddef.h>  /* for wchar_t */
40
#include <stddef.h>  /* for wchar_t */
Lines 155-161 __LA_DECL int archive_version_number(void); Link Here
155
/*
155
/*
156
 * Textual name/version of the library, useful for version displays.
156
 * Textual name/version of the library, useful for version displays.
157
 */
157
 */
158
#define	ARCHIVE_VERSION_ONLY_STRING "3.7.3"
158
#define	ARCHIVE_VERSION_ONLY_STRING "3.7.4"
159
#define	ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
159
#define	ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
160
__LA_DECL const char *	archive_version_string(void);
160
__LA_DECL const char *	archive_version_string(void);
161
161
Lines 895-901 __LA_DECL int archive_write_set_options(struct archive *_a, Link Here
895
			    const char *opts);
895
			    const char *opts);
896
896
897
/*
897
/*
898
 * Set a encryption passphrase.
898
 * Set an encryption passphrase.
899
 */
899
 */
900
__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
900
__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
901
__LA_DECL int archive_write_set_passphrase_callback(struct archive *,
901
__LA_DECL int archive_write_set_passphrase_callback(struct archive *,
(-)b/contrib/libarchive/libarchive/archive_entry.h (-1 / +1 lines)
Lines 28-34 Link Here
28
#define	ARCHIVE_ENTRY_H_INCLUDED
28
#define	ARCHIVE_ENTRY_H_INCLUDED
29
29
30
/* Note: Compiler will complain if this does not match archive.h! */
30
/* Note: Compiler will complain if this does not match archive.h! */
31
#define	ARCHIVE_VERSION_NUMBER 3007003
31
#define	ARCHIVE_VERSION_NUMBER 3007004
32
32
33
/*
33
/*
34
 * Note: archive_entry.h is for use outside of libarchive; the
34
 * Note: archive_entry.h is for use outside of libarchive; the
(-)b/contrib/libarchive/libarchive/archive_entry_acl.3 (-1 / +1 lines)
Lines 383-389 Prefix each default ACL entry with the word Link Here
383
The mask and other ACLs don not contain a double colon.
383
The mask and other ACLs don not contain a double colon.
384
.El
384
.El
385
.Pp
385
.Pp
386
The following flags are effecive only on NFSv4 ACL:
386
The following flags are effective only on NFSv4 ACL:
387
.Bl -tag -offset indent -compact -width ARCHIV
387
.Bl -tag -offset indent -compact -width ARCHIV
388
.It Dv ARCHIVE_ENTRY_ACL_STYLE_COMPACT
388
.It Dv ARCHIVE_ENTRY_ACL_STYLE_COMPACT
389
Do not output minus characters for unset permissions and flags in NFSv4 ACL
389
Do not output minus characters for unset permissions and flags in NFSv4 ACL
(-)b/contrib/libarchive/libarchive/archive_read_disk.3 (-2 / +2 lines)
Lines 288-298 calls. If matched based on calls to Link Here
288
.Tn archive_match_time_excluded ,
288
.Tn archive_match_time_excluded ,
289
or
289
or
290
.Tn archive_match_owner_excluded ,
290
.Tn archive_match_owner_excluded ,
291
then the callback function specified by the _excluded_func parameter will execute. This function will recieve data provided to the fourth parameter, void *_client_data.
291
then the callback function specified by the _excluded_func parameter will execute. This function will receive data provided to the fourth parameter, void *_client_data.
292
.It Fn archive_read_disk_set_metadata_filter_callback
292
.It Fn archive_read_disk_set_metadata_filter_callback
293
Allows the caller to set a callback function during calls to
293
Allows the caller to set a callback function during calls to
294
.Xr archive_read_header 3
294
.Xr archive_read_header 3
295
to filter out metadata for each entry. The callback function recieves the
295
to filter out metadata for each entry. The callback function receives the
296
.Tn struct archive
296
.Tn struct archive
297
object, void* custom filter data, and the 
297
object, void* custom filter data, and the 
298
.Tn struct archive_entry .
298
.Tn struct archive_entry .
(-)b/contrib/libarchive/libarchive/archive_read_support_format_7zip.c (+2 lines)
Lines 2037-2042 read_Folder(struct archive_read *a, struct _7z_folder *f) Link Here
2037
			if (parse_7zip_uint64(
2037
			if (parse_7zip_uint64(
2038
			    a, &(f->coders[i].propertiesSize)) < 0)
2038
			    a, &(f->coders[i].propertiesSize)) < 0)
2039
				return (-1);
2039
				return (-1);
2040
			if (UMAX_ENTRY < f->coders[i].propertiesSize)
2041
				return (-1);
2040
			if ((p = header_bytes(
2042
			if ((p = header_bytes(
2041
			    a, (size_t)f->coders[i].propertiesSize)) == NULL)
2043
			    a, (size_t)f->coders[i].propertiesSize)) == NULL)
2042
				return (-1);
2044
				return (-1);
(-)b/contrib/libarchive/libarchive/archive_read_support_format_all.c (-1 / +1 lines)
Lines 67-73 archive_read_support_format_all(struct archive *a) Link Here
67
	 * increase the chance that a high bid from someone else will
67
	 * increase the chance that a high bid from someone else will
68
	 * make it unnecessary for these to do anything at all.
68
	 * make it unnecessary for these to do anything at all.
69
	 */
69
	 */
70
	/* These three have potentially large look-ahead. */
70
	/* These have potentially large look-ahead. */
71
	archive_read_support_format_7zip(a);
71
	archive_read_support_format_7zip(a);
72
	archive_read_support_format_cab(a);
72
	archive_read_support_format_cab(a);
73
	archive_read_support_format_rar(a);
73
	archive_read_support_format_rar(a);
(-)b/contrib/libarchive/libarchive/archive_read_support_format_ar.c (-2 / +2 lines)
Lines 270-276 _ar_read_header(struct archive_read *a, struct archive_entry *entry, Link Here
270
		}
270
		}
271
		if (ar->strtab != NULL) {
271
		if (ar->strtab != NULL) {
272
			archive_set_error(&a->archive, EINVAL,
272
			archive_set_error(&a->archive, EINVAL,
273
			    "More than one string tables exist");
273
			    "More than one string table exists");
274
			return (ARCHIVE_FATAL);
274
			return (ARCHIVE_FATAL);
275
		}
275
		}
276
276
Lines 515-521 archive_read_format_ar_read_data(struct archive_read *a, Link Here
515
		if (ar->entry_padding) {
515
		if (ar->entry_padding) {
516
			if (skipped >= 0) {
516
			if (skipped >= 0) {
517
				archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
517
				archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
518
					"Truncated ar archive- failed consuming padding");
518
					"Truncated ar archive - failed consuming padding");
519
			}
519
			}
520
			return (ARCHIVE_FATAL);
520
			return (ARCHIVE_FATAL);
521
		}
521
		}
(-)b/contrib/libarchive/libarchive/archive_read_support_format_lha.c (-2 / +2 lines)
Lines 1693-1699 archive_read_format_lha_cleanup(struct archive_read *a) Link Here
1693
 * example.
1693
 * example.
1694
 *   1. a symbolic-name is 'aaa/bb/cc'
1694
 *   1. a symbolic-name is 'aaa/bb/cc'
1695
 *   2. a filename is 'xxx/bbb'
1695
 *   2. a filename is 'xxx/bbb'
1696
 *  then a archived pathname is 'xxx/bbb|aaa/bb/cc'
1696
 *  then an archived pathname is 'xxx/bbb|aaa/bb/cc'
1697
 */
1697
 */
1698
static int
1698
static int
1699
lha_parse_linkname(struct archive_wstring *linkname,
1699
lha_parse_linkname(struct archive_wstring *linkname,
Lines 2385-2391 lzh_decode_blocks(struct lzh_stream *strm, int last) Link Here
2385
					return (100);
2385
					return (100);
2386
				}
2386
				}
2387
2387
2388
				/* lzh_br_read_ahead() always try to fill the
2388
				/* lzh_br_read_ahead() always tries to fill the
2389
				 * cache buffer up. In specific situation we
2389
				 * cache buffer up. In specific situation we
2390
				 * are close to the end of the data, the cache
2390
				 * are close to the end of the data, the cache
2391
				 * buffer will not be full and thus we have to
2391
				 * buffer will not be full and thus we have to
(-)b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c (-4 / +4 lines)
Lines 416-423 next_line(struct archive_read *a, Link Here
416
}
416
}
417
417
418
/*
418
/*
419
 * Compare characters with a mtree keyword.
419
 * Compare characters with an mtree keyword.
420
 * Returns the length of a mtree keyword if matched.
420
 * Returns the length of an mtree keyword if matched.
421
 * Returns 0 if not matched.
421
 * Returns 0 if not matched.
422
 */
422
 */
423
static int
423
static int
Lines 515-521 bid_keyword(const char *p, ssize_t len) Link Here
515
515
516
/*
516
/*
517
 * Test whether there is a set of mtree keywords.
517
 * Test whether there is a set of mtree keywords.
518
 * Returns the number of keyword.
518
 * Returns the number of keywords.
519
 * Returns -1 if we got incorrect sequence.
519
 * Returns -1 if we got incorrect sequence.
520
 * This function expects a set of "<space characters>keyword=value".
520
 * This function expects a set of "<space characters>keyword=value".
521
 * When "unset" is specified, expects a set of "<space characters>keyword".
521
 * When "unset" is specified, expects a set of "<space characters>keyword".
Lines 760-766 detect_form(struct archive_read *a, int *is_form_d) Link Here
760
					multiline = 1;
760
					multiline = 1;
761
				else {
761
				else {
762
					/* We've got plenty of correct lines
762
					/* We've got plenty of correct lines
763
					 * to assume that this file is a mtree
763
					 * to assume that this file is an mtree
764
					 * format. */
764
					 * format. */
765
					if (++entry_cnt >= MAX_BID_ENTRY)
765
					if (++entry_cnt >= MAX_BID_ENTRY)
766
						break;
766
						break;
(-)b/contrib/libarchive/libarchive/archive_read_support_format_rar.c (-1 / +14 lines)
Lines 2176-2181 read_data_compressed(struct archive_read *a, const void **buff, size_t *size, Link Here
2176
    {
2176
    {
2177
      start = rar->offset;
2177
      start = rar->offset;
2178
      end = start + rar->dictionary_size;
2178
      end = start + rar->dictionary_size;
2179
2180
      /* We don't want to overflow the window and overwrite data that we write
2181
       * at 'start'. Therefore, reduce the end length by the maximum match size,
2182
       * which is 260 bytes. You can compute this maximum by looking at the
2183
       * definition of 'expand', in particular when 'symbol >= 271'. */
2184
      /* NOTE: It's possible for 'dictionary_size' to be less than this 260
2185
       * value, however that will only be the case when 'unp_size' is small,
2186
       * which should only happen when the entry size is small and there's no
2187
       * risk of overflowing the buffer */
2188
      if (rar->dictionary_size > 260) {
2189
        end -= 260;
2190
      }
2191
2179
      if (rar->filters.filterstart < end) {
2192
      if (rar->filters.filterstart < end) {
2180
        end = rar->filters.filterstart;
2193
        end = rar->filters.filterstart;
2181
      }
2194
      }
Lines 3615-3621 execute_filter_e8(struct rar_filter *filter, struct rar_virtual_machine *vm, siz Link Here
3615
  uint32_t filesize = 0x1000000;
3628
  uint32_t filesize = 0x1000000;
3616
  uint32_t i;
3629
  uint32_t i;
3617
3630
3618
  if (length > PROGRAM_WORK_SIZE || length < 4)
3631
  if (length > PROGRAM_WORK_SIZE || length <= 4)
3619
    return 0;
3632
    return 0;
3620
3633
3621
  for (i = 0; i <= length - 5; i++)
3634
  for (i = 0; i <= length - 5; i++)
(-)b/contrib/libarchive/libarchive/archive_read_support_format_warc.c (-1 / +9 lines)
Lines 215-220 _warc_rdhdr(struct archive_read *a, struct archive_entry *entry) Link Here
215
	const char *buf;
215
	const char *buf;
216
	ssize_t nrd;
216
	ssize_t nrd;
217
	const char *eoh;
217
	const char *eoh;
218
	char *tmp;
218
	/* for the file name, saves some strndup()'ing */
219
	/* for the file name, saves some strndup()'ing */
219
	warc_string_t fnam;
220
	warc_string_t fnam;
220
	/* warc record type, not that we really use it a lot */
221
	/* warc record type, not that we really use it a lot */
Lines 321-327 _warc_rdhdr(struct archive_read *a, struct archive_entry *entry) Link Here
321
		 * malloc()+free() roundtrip */
322
		 * malloc()+free() roundtrip */
322
		if (fnam.len + 1U > w->pool.len) {
323
		if (fnam.len + 1U > w->pool.len) {
323
			w->pool.len = ((fnam.len + 64U) / 64U) * 64U;
324
			w->pool.len = ((fnam.len + 64U) / 64U) * 64U;
324
			w->pool.str = realloc(w->pool.str, w->pool.len);
325
			tmp = realloc(w->pool.str, w->pool.len);
326
			if (tmp == NULL) {
327
				archive_set_error(
328
					&a->archive, ENOMEM,
329
					"Out of memory");
330
				return (ARCHIVE_FATAL);
331
			}
332
			w->pool.str = tmp;
325
		}
333
		}
326
		memcpy(w->pool.str, fnam.str, fnam.len);
334
		memcpy(w->pool.str, fnam.str, fnam.len);
327
		w->pool.str[fnam.len] = '\0';
335
		w->pool.str[fnam.len] = '\0';
(-)b/contrib/libarchive/libarchive/archive_read_support_format_xar.c (+5 lines)
Lines 2055-2060 xml_start(struct archive_read *a, const char *name, struct xmlattr_list *list) Link Here
2055
			    attr = attr->next) {
2055
			    attr = attr->next) {
2056
				if (strcmp(attr->name, "link") != 0)
2056
				if (strcmp(attr->name, "link") != 0)
2057
					continue;
2057
					continue;
2058
				if (xar->file->hdnext != NULL || xar->file->link != 0) {
2059
					archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
2060
					    "File with multiple link targets");
2061
					return (ARCHIVE_FATAL);
2062
				}
2058
				if (strcmp(attr->value, "original") == 0) {
2063
				if (strcmp(attr->value, "original") == 0) {
2059
					xar->file->hdnext = xar->hdlink_orgs;
2064
					xar->file->hdnext = xar->hdlink_orgs;
2060
					xar->hdlink_orgs = xar->file;
2065
					xar->hdlink_orgs = xar->file;
(-)b/contrib/libarchive/libarchive/archive_read_support_format_zip.c (-2 / +13 lines)
Lines 1393-1399 check_authentication_code(struct archive_read *a, const void *_p) Link Here
1393
 *  [CRC32] [compressed low] [compressed high] [uncompressed low] [uncompressed high] [other PK marker]
1393
 *  [CRC32] [compressed low] [compressed high] [uncompressed low] [uncompressed high] [other PK marker]
1394
 * ```
1394
 * ```
1395
 * Since the 32-bit and 64-bit compressed sizes both match, the
1395
 * Since the 32-bit and 64-bit compressed sizes both match, the
1396
 * actualy size must fit in 32 bits, which implies the high-order
1396
 * actual size must fit in 32 bits, which implies the high-order
1397
 * word of the compressed size is zero.  So we know the uncompressed
1397
 * word of the compressed size is zero.  So we know the uncompressed
1398
 * low word is zero, which again implies that if we accept the shorter
1398
 * low word is zero, which again implies that if we accept the shorter
1399
 * format, there will not be a valid PK marker following it.
1399
 * format, there will not be a valid PK marker following it.
Lines 4083-4088 slurp_central_directory(struct archive_read *a, struct archive_entry* entry, Link Here
4083
			} else {
4083
			} else {
4084
				/* Generate resource fork name to find its
4084
				/* Generate resource fork name to find its
4085
				 * resource file at zip->tree_rsrc. */
4085
				 * resource file at zip->tree_rsrc. */
4086
4087
				/* If this is an entry ending with slash,
4088
				 * make the resource for name slash-less
4089
				 * as the actual resource fork doesn't end with '/'.
4090
				 */
4091
				size_t tmp_length = filename_length;
4092
				if (tmp_length > 0 && name[tmp_length - 1] == '/') {
4093
					tmp_length--;
4094
					r = rsrc_basename(name, tmp_length);
4095
				}
4096
4086
				archive_strcpy(&(zip_entry->rsrcname),
4097
				archive_strcpy(&(zip_entry->rsrcname),
4087
				    "__MACOSX/");
4098
				    "__MACOSX/");
4088
				archive_strncat(&(zip_entry->rsrcname),
4099
				archive_strncat(&(zip_entry->rsrcname),
Lines 4090-4096 slurp_central_directory(struct archive_read *a, struct archive_entry* entry, Link Here
4090
				archive_strcat(&(zip_entry->rsrcname), "._");
4101
				archive_strcat(&(zip_entry->rsrcname), "._");
4091
				archive_strncat(&(zip_entry->rsrcname),
4102
				archive_strncat(&(zip_entry->rsrcname),
4092
				    name + (r - name),
4103
				    name + (r - name),
4093
				    filename_length - (r - name));
4104
				    tmp_length - (r - name));
4094
				/* Register an entry to RB tree to sort it by
4105
				/* Register an entry to RB tree to sort it by
4095
				 * file offset. */
4106
				 * file offset. */
4096
				__archive_rb_tree_insert_node(&zip->tree,
4107
				__archive_rb_tree_insert_node(&zip->tree,
(-)b/contrib/libarchive/libarchive/archive_util.c (-2 / +1 lines)
Lines 255-264 __archive_mktempx(const char *tmpdir, wchar_t *template) Link Here
255
#endif
255
#endif
256
	fd = -1;
256
	fd = -1;
257
	ws = NULL;
257
	ws = NULL;
258
	archive_string_init(&temp_name);
258
259
259
	if (template == NULL) {
260
	if (template == NULL) {
260
		archive_string_init(&temp_name);
261
262
		/* Get a temporary directory. */
261
		/* Get a temporary directory. */
263
		if (tmpdir == NULL) {
262
		if (tmpdir == NULL) {
264
			size_t l;
263
			size_t l;
(-)b/contrib/libarchive/libarchive/archive_write_add_filter_zstd.c (-1 / +22 lines)
Lines 29-34 Link Here
29
#ifdef HAVE_ERRNO_H
29
#ifdef HAVE_ERRNO_H
30
#include <errno.h>
30
#include <errno.h>
31
#endif
31
#endif
32
#ifdef HAVE_LIMITS_H
33
#include <limits.h>
34
#endif
32
#ifdef HAVE_STDINT_H
35
#ifdef HAVE_STDINT_H
33
#include <stdint.h>
36
#include <stdint.h>
34
#endif
37
#endif
Lines 38-43 Link Here
38
#ifdef HAVE_STRING_H
41
#ifdef HAVE_STRING_H
39
#include <string.h>
42
#include <string.h>
40
#endif
43
#endif
44
#ifdef HAVE_UNISTD_H
45
#include <unistd.h>
46
#endif
41
#ifdef HAVE_ZSTD_H
47
#ifdef HAVE_ZSTD_H
42
#include <zstd.h>
48
#include <zstd.h>
43
#endif
49
#endif
Lines 190-195 string_to_number(const char *string, intmax_t *numberp) Link Here
190
	return (ARCHIVE_OK);
196
	return (ARCHIVE_OK);
191
}
197
}
192
198
199
#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
193
static int
200
static int
194
string_to_size(const char *string, size_t *numberp)
201
string_to_size(const char *string, size_t *numberp)
195
{
202
{
Lines 224-229 string_to_size(const char *string, size_t *numberp) Link Here
224
	*numberp = (size_t)(number << shift);
231
	*numberp = (size_t)(number << shift);
225
	return (ARCHIVE_OK);
232
	return (ARCHIVE_OK);
226
}
233
}
234
#endif
227
235
228
/*
236
/*
229
 * Set write options.
237
 * Set write options.
Lines 264-270 archive_compressor_zstd_options(struct archive_write_filter *f, const char *key, Link Here
264
		if (string_to_number(value, &threads) != ARCHIVE_OK) {
272
		if (string_to_number(value, &threads) != ARCHIVE_OK) {
265
			return (ARCHIVE_WARN);
273
			return (ARCHIVE_WARN);
266
		}
274
		}
267
		if (threads < 0) {
275
276
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
277
		if (threads == 0) {
278
			threads = sysconf(_SC_NPROCESSORS_ONLN);
279
		}
280
#elif !defined(__CYGWIN__) && defined(_WIN32_WINNT) && \
281
    _WIN32_WINNT >= 0x0601 /* _WIN32_WINNT_WIN7 */
282
		if (threads == 0) {
283
			DWORD winCores = GetActiveProcessorCount(
284
			    ALL_PROCESSOR_GROUPS);
285
			threads = (intmax_t)winCores;
286
		}
287
#endif
288
		if (threads < 0 || threads > INT_MAX) {
268
			return (ARCHIVE_WARN);
289
			return (ARCHIVE_WARN);
269
		}
290
		}
270
		data->threads = (int)threads;
291
		data->threads = (int)threads;
(-)b/contrib/libarchive/libarchive/archive_write_disk_posix.c (-1 / +2 lines)
Lines 4427-4433 fixup_appledouble(struct archive_write_disk *a, const char *pathname) Link Here
4427
#else
4427
#else
4428
		la_stat(datafork.s, &st) == -1 ||
4428
		la_stat(datafork.s, &st) == -1 ||
4429
#endif
4429
#endif
4430
	    (st.st_mode & AE_IFMT) != AE_IFREG)
4430
	    (((st.st_mode & AE_IFMT) != AE_IFREG) &&
4431
		((st.st_mode & AE_IFMT) != AE_IFDIR)))
4431
		goto skip_appledouble;
4432
		goto skip_appledouble;
4432
4433
4433
	/*
4434
	/*
(-)b/contrib/libarchive/libarchive/archive_write_private.h (-1 / +1 lines)
Lines 158-164 int __archive_write_program_write(struct archive_write_filter *, Link Here
158
	    struct archive_write_program_data *, const void *, size_t);
158
	    struct archive_write_program_data *, const void *, size_t);
159
159
160
/*
160
/*
161
 * Get a encryption passphrase.
161
 * Get an encryption passphrase.
162
 */
162
 */
163
const char * __archive_write_get_passphrase(struct archive_write *a);
163
const char * __archive_write_get_passphrase(struct archive_write *a);
164
#endif
164
#endif
(-)b/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c (-1 / +1 lines)
Lines 387-393 archive_write_gnutar_header(struct archive_write *a, Link Here
387
	if (r != 0) {
387
	if (r != 0) {
388
		if (errno == ENOMEM) {
388
		if (errno == ENOMEM) {
389
			archive_set_error(&a->archive, ENOMEM,
389
			archive_set_error(&a->archive, ENOMEM,
390
			    "Can't allocate memory for Pathame");
390
			    "Can't allocate memory for pathname");
391
			ret = ARCHIVE_FATAL;
391
			ret = ARCHIVE_FATAL;
392
			goto exit_write_header;
392
			goto exit_write_header;
393
		}
393
		}
(-)b/contrib/libarchive/libarchive/archive_write_set_passphrase.c (-17 / +18 lines)
Lines 30-43 Link Here
30
#endif
30
#endif
31
#include "archive_write_private.h"
31
#include "archive_write_private.h"
32
32
33
int
33
static int
34
archive_write_set_passphrase(struct archive *_a, const char *p)
34
set_passphrase(struct archive_write *a, const char *p)
35
{
35
{
36
	struct archive_write *a = (struct archive_write *)_a;
37
38
	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_NEW,
39
		"archive_write_set_passphrase");
40
41
	if (p == NULL || p[0] == '\0') {
36
	if (p == NULL || p[0] == '\0') {
42
		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
37
		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
43
		    "Empty passphrase is unacceptable");
38
		    "Empty passphrase is unacceptable");
Lines 54-59 archive_write_set_passphrase(struct archive *_a, const char *p) Link Here
54
}
49
}
55
50
56
51
52
int
53
archive_write_set_passphrase(struct archive *_a, const char *p)
54
{
55
	struct archive_write *a = (struct archive_write *)_a;
56
57
	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_NEW,
58
		"archive_write_set_passphrase");
59
60
	return (set_passphrase(a, p));
61
}
62
63
57
int
64
int
58
archive_write_set_passphrase_callback(struct archive *_a, void *client_data,
65
archive_write_set_passphrase_callback(struct archive *_a, void *client_data,
59
    archive_passphrase_callback *cb)
66
    archive_passphrase_callback *cb)
Lines 80-94 __archive_write_get_passphrase(struct archive_write *a) Link Here
80
		const char *p;
87
		const char *p;
81
		p = a->passphrase_callback(&a->archive,
88
		p = a->passphrase_callback(&a->archive,
82
		    a->passphrase_client_data);
89
		    a->passphrase_client_data);
83
		if (p != NULL) {
90
		set_passphrase(a, p);
84
			a->passphrase = strdup(p);
91
		a->passphrase_callback = NULL;
85
			if (a->passphrase == NULL) {
92
		a->passphrase_client_data = NULL;
86
				archive_set_error(&a->archive, ENOMEM,
87
				    "Can't allocate data for passphrase");
88
				return (NULL);
89
			}
90
			return (a->passphrase);
91
		}
92
	}
93
	}
93
	return (NULL);
94
	return (a->passphrase);
94
}
95
}
(-)b/contrib/libarchive/libarchive/libarchive_internals.3 (-1 / +1 lines)
Lines 124-130 to read the entire file into memory at once and return the Link Here
124
entire file to libarchive as a single block;
124
entire file to libarchive as a single block;
125
other clients may begin asynchronous I/O operations for the
125
other clients may begin asynchronous I/O operations for the
126
next block on each request.
126
next block on each request.
127
.Ss Decompresssion Layer
127
.Ss Decompression Layer
128
The decompression layer not only handles decompression,
128
The decompression layer not only handles decompression,
129
it also buffers data so that the format handlers see a
129
it also buffers data so that the format handlers see a
130
much nicer I/O model.
130
much nicer I/O model.
(-)b/contrib/libarchive/libarchive/test/test_read_format_xar_doublelink.c (+55 lines)
Added Link Here
1
/*-
2
 * Copyright (c) 2024 Martin Matuska
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
#include "test.h"
26
27
#define __LIBARCHIVE_BUILD
28
29
DEFINE_TEST(test_read_format_xar_doublelink)
30
{
31
	const char *refname = "test_read_format_xar_doublelink.xar";
32
	struct archive *a;
33
	struct archive_entry *ae;
34
35
	extract_reference_file(refname);
36
37
	/* Verify with seeking reader. */
38
	assert((a = archive_read_new()) != NULL);
39
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
40
        if(ARCHIVE_OK != archive_read_support_format_xar(a)) {
41
                skipping("XAR format unsupported");
42
                assertEqualInt(ARCHIVE_OK, archive_read_free(a));
43
                return;
44
        }
45
	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname,
46
	    10240));
47
48
	assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
49
	assertEqualString(archive_error_string(a),
50
		"File with multiple link targets");
51
	assert(archive_errno(a) != 0);
52
53
	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
54
	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
55
}
(-)b/contrib/libarchive/libarchive/test/test_read_format_xar_doublelink.xar.uu (+12 lines)
Added Link Here
1
begin 664 test_read_format_xar_doublelink.xar
2
M>&%R(0`<``$````````!0`````````/7`````7B<[9/!<L(@%$7W?@7#/H60
3
MU'0R!'?]`KOICDF>D3&``]'1?GT!-1U;;:=[5[G<=WB0=P>^..@![<%Y94V#
4
M\R>*$9C6=LKT#7Y;OF8O>"%F_""=F"$^VC9\$&\=R#'LR$:E03#*RHR6&2N6
5
MM*KIO,YS3JZ1M&D-[<;O-/+C<8`&^[7,<:P@;E<K#Z.@G)Q5<KWZB,TY22*V
6
M()<>:;52`R#5A6N?VQ@9CHIN.#_IY(['+:!!F4V#K5.],G+`8BU=%SU.8OF?
7
MH#*V`U%5K"@9)Z=5*G2P5RT8*YY+3J9%*ND(T?D\%/3$[U0G<DK#+T9ULCPX
8
MH75PHDA6/U']A>J=W6T3=E+);&^E4=0%?0^#N\00;G(;8U7`]!<F?\'D%"J)
9
MX[Y.@WU/@]U)(_\SACO$8_X_YA_&$]\F)^FE?@)<4AJ<B%QTTZN3JTL:$,<5
10
<`XH;(KD-Q0=XG.V3P7+"(!1%]WX%PSZ%D-1T,@``
11
`
12
end
(-)b/contrib/libarchive/libarchive/test/test_write_disk_appledouble.c (+84 lines)
Lines 236-238 DEFINE_TEST(test_write_disk_appledouble) Link Here
236
	assertEqualFile("hfscmp/file3", "nocmp/file3");
236
	assertEqualFile("hfscmp/file3", "nocmp/file3");
237
#endif
237
#endif
238
}
238
}
239
240
/* Test writing apple doubles to disk from zip format */
241
DEFINE_TEST(test_write_disk_appledouble_zip)
242
{
243
#if !defined(__APPLE__) || !defined(UF_COMPRESSED) || !defined(HAVE_SYS_XATTR_H)\
244
	|| !defined(HAVE_ZLIB_H)
245
	skipping("MacOS-specific AppleDouble test");
246
#else
247
	const char *refname = "test_write_disk_appledouble_zip.zip";
248
	struct archive *ad, *a;
249
	struct archive_entry *ae;
250
	struct stat st;
251
252
	extract_reference_file(refname);
253
254
	/*
255
	 * Extract an archive to disk.
256
	 */
257
	assert((ad = archive_write_disk_new()) != NULL);
258
	assertEqualIntA(ad, ARCHIVE_OK,
259
	    archive_write_disk_set_standard_lookup(ad));
260
	assertEqualIntA(ad, ARCHIVE_OK,
261
	    archive_write_disk_set_options(ad,
262
		ARCHIVE_EXTRACT_TIME |
263
		ARCHIVE_EXTRACT_SECURE_SYMLINKS |
264
		ARCHIVE_EXTRACT_SECURE_NODOTDOT));
265
266
	assert((a = archive_read_new()) != NULL);
267
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
268
	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
269
	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a,
270
	    refname, 512 * 20));
271
272
	/* Skip The top level directory */
273
	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
274
	assertEqualString("apple_double_dir/", archive_entry_pathname(ae));
275
276
	/* Extract apple_double_test */
277
	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
278
	assertEqualString("apple_double_dir/apple_double_dir_test/", archive_entry_pathname(ae));
279
	assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
280
281
	/* Extract ._apple_double_dir_test which will be merged into apple_double_dir_test as metadata. */
282
	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
283
	assertEqualString("apple_double_dir/._apple_double_dir_test", archive_entry_pathname(ae));
284
	assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
285
286
	/* Extract test_file */
287
	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
288
	assertEqualString("apple_double_dir/test_file", archive_entry_pathname(ae));
289
	assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
290
291
	/* Extract ._test_file which will be merged into test_file as metadata. */
292
	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
293
	assertEqualString("apple_double_dir/._test_file", archive_entry_pathname(ae));
294
	assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
295
296
	assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
297
	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
298
	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
299
	assertEqualIntA(ad, ARCHIVE_OK, archive_write_free(ad));
300
301
	/* Test test_file */
302
	assertEqualInt(0, stat("apple_double_dir/test_file", &st));
303
	assertFileSize("apple_double_dir/test_file", 5);
304
	failure("'%s' should have Resource Fork", "test_file");
305
	assertEqualInt(1, has_xattr("apple_double_dir/test_file", "com.apple.ResourceFork"));
306
307
	/* Test apple_double_dir_test */
308
	failure("'%s' should have quarantine xattr", "apple_double_dir_test");
309
	assertEqualInt(1, has_xattr("apple_double_dir/apple_double_dir_test", "com.apple.quarantine"));
310
311
	/* Test ._test_file. */
312
	failure("'apple_double_dir/._test_file' should be merged and removed");
313
	assertFileNotExists("apple_double_dir/._test_file");
314
315
	/* Test ._apple_double_dir_test */
316
	failure("'apple_double_dir/._._apple_double_dir_test' should be merged and removed");
317
	assertFileNotExists("apple_double_dir/._apple_double_dir_test");
318
319
	assertChdir("..");
320
321
#endif
322
}
(-)b/contrib/libarchive/libarchive/test/test_write_disk_appledouble_zip.zip.uu (+27 lines)
Added Link Here
1
begin 644 test_write_disk_appledouble_zip.zip
2
M4$L#!`H```````MM?%@````````````````1`!``87!P;&5?9&]U8FQE7V1I
3
M<B]56`P`O=4%9K75!6;U`10`4$L#!`H```````MM?%@````````````````G
4
M`!``87!P;&5?9&]U8FQE7V1I<B]A<'!L95]D;W5B;&5?9&ER7W1E<W0O55@,
5
M`+W5!6:UU05F]0$4`%!+`P04``@`"``+;7Q8````````````````*``0`&%P
6
M<&QE7V1O=6)L95]D:7(O+E]A<'!L95]D;W5B;&5?9&ER7W1E<W156`P`O=4%
7
M9K75!6;U`10`8V`58V=@8F#P34Q6\`]6B%"``I`8`R<0&P%Q!1"#^*L8B`*.
8
M(2%!4"9(QPP@%D)3PH@0%TW.S]5++"C(2=4K+$TL2LPKR<Q+92C4-S"P,+8V
9
M@`)K:P8`4$L'"!2N=6M7````J@```%!+`P04``@`"`!93GQ8````````````
10
M````&@`0`&%P<&QE7V1O=6)L95]D:7(O=&5S=%]F:6QE55@,`+'5!6;IGP5F
11
M]0$4`"M)+2[A`@!02P<(QC6Y.P<````%````4$L#!!0`"``(`%E.?%@`````
12
M```````````<`!``87!P;&5?9&]U8FQE7V1I<B\N7W1E<W1?9FEL9558#`"Q
13
MU05FZ9\%9O4!%`!C8!5C9V!B8/!-3%;P#U:(4(`"D!@#)Q`;`;$;$(/X%4#,
14
MQT`0.(:$!$&9%5",`8I2B_-+BY)3%=+RB[*Y`%!+!P@HPLP3/@```(8```!0
15
M2P$"%0,*```````+;7Q8````````````````$0`,``````````!`[4$`````
16
M87!P;&5?9&]U8FQE7V1I<B]56`@`O=4%9K75!6902P$"%0,*```````+;7Q8
17
M````````````````)P`,``````````!`[4$_````87!P;&5?9&]U8FQE7V1I
18
M<B]A<'!L95]D;W5B;&5?9&ER7W1E<W0O55@(`+W5!6:UU05F4$L!`A4#%``(
19
M``@`"VU\6!2N=6M7````J@```"@`#```````````0*2!E````&%P<&QE7V1O
20
M=6)L95]D:7(O+E]A<'!L95]D;W5B;&5?9&ER7W1E<W156`@`O=4%9K75!690
21
M2P$"%0,4``@`"`!93GQ8QC6Y.P<````%````&@`,``````````!`I(%1`0``
22
M87!P;&5?9&]U8FQE7V1I<B]T97-T7V9I;&556`@`L=4%9NF?!6902P$"%0,4
23
M``@`"`!93GQ8*,+,$SX```"&````'``,``````````!`I(&P`0``87!P;&5?
24
M9&]U8FQE7V1I<B\N7W1E<W1?9FEL9558"`"QU05FZ9\%9E!+!08`````!0`%
25
+`+@!``!(`@``````
26
`
27
end
(-)b/contrib/libarchive/libarchive_fe/passphrase.c (-2 / +2 lines)
Lines 76-81 Link Here
76
76
77
77
78
#if defined(_WIN32) && !defined(__CYGWIN__)
78
#if defined(_WIN32) && !defined(__CYGWIN__)
79
#include <string.h>
79
#include <windows.h>
80
#include <windows.h>
80
81
81
static char *
82
static char *
Lines 113-120 readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) Link Here
113
	WriteFile(hStdout, "\r\n", 2, NULL, NULL);
114
	WriteFile(hStdout, "\r\n", 2, NULL, NULL);
114
	buf[rbytes] = '\0';
115
	buf[rbytes] = '\0';
115
	/* Remove trailing carriage return(s). */
116
	/* Remove trailing carriage return(s). */
116
	if (rbytes > 2 && buf[rbytes - 2] == '\r' && buf[rbytes - 1] == '\n')
117
	buf[strcspn(buf, "\r\n")] = '\0';
117
		buf[rbytes - 2] = '\0';
118
118
119
	return (buf);
119
	return (buf);
120
}
120
}
(-)b/contrib/libarchive/tar/bsdtar.1 (-8 / +7 lines)
Lines 23-29 Link Here
23
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
.\" SUCH DAMAGE.
24
.\" SUCH DAMAGE.
25
.\"
25
.\"
26
.Dd March 1, 2024
26
.Dd April 23, 2024
27
.Dt TAR 1
27
.Dt TAR 1
28
.Os
28
.Os
29
.Sh NAME
29
.Sh NAME
Lines 644-657 A decimal integer from 4 to 7 specifying the lz4 compression block size Link Here
644
.It Cm lz4:block-dependence
644
.It Cm lz4:block-dependence
645
Use the previous block of the block being compressed for
645
Use the previous block of the block being compressed for
646
a compression dictionary to improve compression ratio.
646
a compression dictionary to improve compression ratio.
647
.It Cm zstd:compression-level
647
.It Cm zstd:compression-level Ns = Ns Ar N
648
A decimal integer specifying the zstd compression level. Supported values depend
648
A decimal integer specifying the zstd compression level.
649
Supported values depend
649
on the library version, common values are from 1 to 22.
650
on the library version, common values are from 1 to 22.
650
.It Cm zstd:threads
651
.It Cm zstd:threads Ns = Ns Ar N
651
Specify the number of worker threads to use.
652
Specify the number of worker threads to use, or 0 to use as many
652
Setting threads to a special value 0 makes
653
threads as there are CPU cores in the system.
653
.Xr zstd 1
654
use as many threads as there are CPU cores on the system.
655
.It Cm zstd:frame-per-file
654
.It Cm zstd:frame-per-file
656
Start a new compression frame at the beginning of each file in the
655
Start a new compression frame at the beginning of each file in the
657
archive.
656
archive.
(-)b/contrib/libarchive/tar/bsdtar.c (-34 / +29 lines)
Lines 157-162 main(int argc, char **argv) Link Here
157
	char			*tptr, *uptr;
157
	char			*tptr, *uptr;
158
	char			 possible_help_request;
158
	char			 possible_help_request;
159
	char			 buff[16];
159
	char			 buff[16];
160
	long			 l;
160
161
161
	/*
162
	/*
162
	 * Use a pointer for consistency, but stack-allocated storage
163
	 * Use a pointer for consistency, but stack-allocated storage
Lines 301-316 main(int argc, char **argv) Link Here
301
			/* libarchive doesn't need this; just ignore it. */
302
			/* libarchive doesn't need this; just ignore it. */
302
			break;
303
			break;
303
		case 'b': /* SUSv2 */
304
		case 'b': /* SUSv2 */
304
			errno = 0;
305
			tptr = NULL;
305
			tptr = NULL;
306
			t = (int)strtol(bsdtar->argument, &tptr, 10);
306
			l = strtol(bsdtar->argument, &tptr, 10);
307
			if (errno || t <= 0 || t > 8192 ||
307
			if (l <= 0 || l > 8192L ||
308
			    *(bsdtar->argument) == '\0' || tptr == NULL ||
308
			    *(bsdtar->argument) == '\0' || tptr == NULL ||
309
			    *tptr != '\0') {
309
			    *tptr != '\0') {
310
				lafe_errc(1, 0, "Invalid or out of range "
310
				lafe_errc(1, 0, "Invalid or out of range "
311
				    "(1..8192) argument to -b");
311
				    "(1..8192) argument to -b");
312
			}
312
			}
313
			bsdtar->bytes_per_block = 512 * t;
313
			bsdtar->bytes_per_block = 512 * (int)l;
314
			/* Explicit -b forces last block size. */
314
			/* Explicit -b forces last block size. */
315
			bsdtar->bytes_in_last_block = bsdtar->bytes_per_block;
315
			bsdtar->bytes_in_last_block = bsdtar->bytes_per_block;
316
			break;
316
			break;
Lines 369-412 main(int argc, char **argv) Link Here
369
			bsdtar->filename = bsdtar->argument;
369
			bsdtar->filename = bsdtar->argument;
370
			break;
370
			break;
371
		case OPTION_GID: /* cpio */
371
		case OPTION_GID: /* cpio */
372
			errno = 0;
373
			tptr = NULL;
372
			tptr = NULL;
374
			t = (int)strtol(bsdtar->argument, &tptr, 10);
373
			l = strtol(bsdtar->argument, &tptr, 10);
375
			if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
374
			if (l < 0 || l >= INT_MAX || *(bsdtar->argument) == '\0' ||
376
			    tptr == NULL || *tptr != '\0') {
375
			    tptr == NULL || *tptr != '\0') {
377
				lafe_errc(1, 0, "Invalid argument to --gid");
376
				lafe_errc(1, 0, "Invalid argument to --gid");
378
			}
377
			}
379
			bsdtar->gid = t;
378
			bsdtar->gid = (int)l;
380
			break;
379
			break;
381
		case OPTION_GNAME: /* cpio */
380
		case OPTION_GNAME: /* cpio */
382
			bsdtar->gname = bsdtar->argument;
381
			bsdtar->gname = bsdtar->argument;
383
			break;
382
			break;
384
		case OPTION_GROUP: /* GNU tar */
383
		case OPTION_GROUP: /* GNU tar */
385
			errno = 0;
386
			tptr = NULL;
384
			tptr = NULL;
387
385
388
			uptr = strchr(bsdtar->argument, ':');
386
			uptr = strchr(bsdtar->argument, ':');
389
			if(uptr != NULL) {
387
			if (uptr != NULL) {
390
				if(uptr[1] == 0) {
388
				if (uptr[1] == '\0') {
391
					lafe_errc(1, 0, "Invalid argument to --group (missing id after :)");
389
					lafe_errc(1, 0, "Invalid argument to --group (missing id after :)");
392
				}
390
				}
393
				uptr[0] = 0;
391
				uptr[0] = 0;
394
				uptr++;
392
				uptr++;
395
				t = (int)strtol(uptr, &tptr, 10);
393
				l = strtol(uptr, &tptr, 10);
396
				if (errno || t < 0 || *uptr == '\0' ||
394
				if (l < 0 || l >= INT_MAX || *uptr == '\0' ||
397
				    tptr == NULL || *tptr != '\0') {
395
				    tptr == NULL || *tptr != '\0') {
398
					lafe_errc(1, 0, "Invalid argument to --group (%s is not a number)", uptr);
396
					lafe_errc(1, 0, "Invalid argument to --group (%s is not a number)", uptr);
399
				} else {
397
				} else {
400
					bsdtar->gid = t;
398
					bsdtar->gid = (int)l;
401
				}
399
				}
402
				bsdtar->gname = bsdtar->argument;
400
				bsdtar->gname = bsdtar->argument;
403
			} else {
401
			} else {
404
				t = (int)strtol(bsdtar->argument, &tptr, 10);
402
				l = strtol(bsdtar->argument, &tptr, 10);
405
				if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
403
				if (l < 0 || l >= INT_MAX || *(bsdtar->argument) == '\0' ||
406
				    tptr == NULL || *tptr != '\0') {
404
				    tptr == NULL || *tptr != '\0') {
407
					bsdtar->gname = bsdtar->argument;
405
					bsdtar->gname = bsdtar->argument;
408
				} else {
406
				} else {
409
					bsdtar->gid = t;
407
					bsdtar->gid = (int)l;
410
					bsdtar->gname = "";
408
					bsdtar->gname = "";
411
				}
409
				}
412
			}
410
			}
Lines 662-692 main(int argc, char **argv) Link Here
662
			bsdtar->option_options = bsdtar->argument;
660
			bsdtar->option_options = bsdtar->argument;
663
			break;
661
			break;
664
		case OPTION_OWNER: /* GNU tar */
662
		case OPTION_OWNER: /* GNU tar */
665
			errno = 0;
666
			tptr = NULL;
663
			tptr = NULL;
667
664
668
			uptr = strchr(bsdtar->argument, ':');
665
			uptr = strchr(bsdtar->argument, ':');
669
			if(uptr != NULL) {
666
			if (uptr != NULL) {
670
				if(uptr[1] == 0) {
667
				if (uptr[1] == 0) {
671
					lafe_errc(1, 0, "Invalid argument to --owner (missing id after :)");
668
					lafe_errc(1, 0, "Invalid argument to --owner (missing id after :)");
672
				}
669
				}
673
				uptr[0] = 0;
670
				uptr[0] = 0;
674
				uptr++;
671
				uptr++;
675
				t = (int)strtol(uptr, &tptr, 10);
672
				l = strtol(uptr, &tptr, 10);
676
				if (errno || t < 0 || *uptr == '\0' ||
673
				if (l < 0 || l >= INT_MAX || *uptr == '\0' ||
677
				    tptr == NULL || *tptr != '\0') {
674
				    tptr == NULL || *tptr != '\0') {
678
					lafe_errc(1, 0, "Invalid argument to --owner (%s is not a number)", uptr);
675
					lafe_errc(1, 0, "Invalid argument to --owner (%s is not a number)", uptr);
679
				} else {
676
				} else {
680
					bsdtar->uid = t;
677
					bsdtar->uid = (int)l;
681
				}
678
				}
682
				bsdtar->uname = bsdtar->argument;
679
				bsdtar->uname = bsdtar->argument;
683
			} else {
680
			} else {
684
				t = (int)strtol(bsdtar->argument, &tptr, 10);
681
				l = strtol(bsdtar->argument, &tptr, 10);
685
				if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
682
				if (l < 0 || l >= INT_MAX || *(bsdtar->argument) == '\0' ||
686
				    tptr == NULL || *tptr != '\0') {
683
				    tptr == NULL || *tptr != '\0') {
687
					bsdtar->uname = bsdtar->argument;
684
					bsdtar->uname = bsdtar->argument;
688
				} else {
685
				} else {
689
					bsdtar->uid = t;
686
					bsdtar->uid = (int)l;
690
					bsdtar->uname = "";
687
					bsdtar->uname = "";
691
				}
688
				}
692
			}
689
			}
Lines 748-762 main(int argc, char **argv) Link Here
748
			bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
745
			bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
749
			break;
746
			break;
750
		case OPTION_STRIP_COMPONENTS: /* GNU tar 1.15 */
747
		case OPTION_STRIP_COMPONENTS: /* GNU tar 1.15 */
751
			errno = 0;
752
			tptr = NULL;
748
			tptr = NULL;
753
			t = (int)strtol(bsdtar->argument, &tptr, 10);
749
			l = strtol(bsdtar->argument, &tptr, 10);
754
			if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
750
			if (l < 0 || l > 100000L || *(bsdtar->argument) == '\0' ||
755
			    tptr == NULL || *tptr != '\0') {
751
			    tptr == NULL || *tptr != '\0') {
756
				lafe_errc(1, 0, "Invalid argument to "
752
				lafe_errc(1, 0, "Invalid argument to "
757
				    "--strip-components");
753
				    "--strip-components");
758
			}
754
			}
759
			bsdtar->strip_components = t;
755
			bsdtar->strip_components = (int)l;
760
			break;
756
			break;
761
		case 'T': /* GNU tar */
757
		case 'T': /* GNU tar */
762
			bsdtar->names_from_file = bsdtar->argument;
758
			bsdtar->names_from_file = bsdtar->argument;
Lines 776-789 main(int argc, char **argv) Link Here
776
			set_mode(bsdtar, opt);
772
			set_mode(bsdtar, opt);
777
			break;
773
			break;
778
		case OPTION_UID: /* cpio */
774
		case OPTION_UID: /* cpio */
779
			errno = 0;
780
			tptr = NULL;
775
			tptr = NULL;
781
			t = (int)strtol(bsdtar->argument, &tptr, 10);
776
			l = strtol(bsdtar->argument, &tptr, 10);
782
			if (errno || t < 0 || *(bsdtar->argument) == '\0' ||
777
			if (l < 0 || l >= INT_MAX || *(bsdtar->argument) == '\0' ||
783
			    tptr == NULL || *tptr != '\0') {
778
			    tptr == NULL || *tptr != '\0') {
784
				lafe_errc(1, 0, "Invalid argument to --uid");
779
				lafe_errc(1, 0, "Invalid argument to --uid");
785
			}
780
			}
786
			bsdtar->uid = t;
781
			bsdtar->uid = (int)l;
787
			break;
782
			break;
788
		case OPTION_UNAME: /* cpio */
783
		case OPTION_UNAME: /* cpio */
789
			bsdtar->uname = bsdtar->argument;
784
			bsdtar->uname = bsdtar->argument;
(-)b/contrib/libarchive/tar/cmdline.c (-5 / +11 lines)
Lines 218-229 bsdtar_getopt(struct bsdtar *bsdtar) Link Here
218
	enum { state_start = 0, state_old_tar, state_next_word,
218
	enum { state_start = 0, state_old_tar, state_next_word,
219
	       state_short, state_long };
219
	       state_short, state_long };
220
220
221
	const struct bsdtar_option *popt, *match = NULL, *match2 = NULL;
221
	const struct bsdtar_option *popt, *match, *match2;
222
	const char *p, *long_prefix = "--";
222
	const char *p, *long_prefix;
223
	size_t optlength;
223
	size_t optlength;
224
	int opt = '?';
224
	int opt;
225
	int required = 0;
225
	int required;
226
226
227
again:
228
	match = NULL;
229
	match2 = NULL;
230
	long_prefix = "--";
231
	opt = '?';
232
	required = 0;
227
	bsdtar->argument = NULL;
233
	bsdtar->argument = NULL;
228
234
229
	/* First time through, initialize everything. */
235
	/* First time through, initialize everything. */
Lines 310-316 bsdtar_getopt(struct bsdtar *bsdtar) Link Here
310
		if (opt == '\0') {
316
		if (opt == '\0') {
311
			/* End of this group; recurse to get next option. */
317
			/* End of this group; recurse to get next option. */
312
			bsdtar->getopt_state = state_next_word;
318
			bsdtar->getopt_state = state_next_word;
313
			return bsdtar_getopt(bsdtar);
319
			goto again;
314
		}
320
		}
315
321
316
		/* Does this option take an argument? */
322
		/* Does this option take an argument? */
(-)b/contrib/libarchive/unzip/cmdline.c (-6 / +12 lines)
Lines 81-92 bsdunzip_getopt(struct bsdunzip *bsdunzip) Link Here
81
{
81
{
82
	enum { state_start = 0, state_next_word, state_short, state_long };
82
	enum { state_start = 0, state_next_word, state_short, state_long };
83
83
84
	const struct bsdunzip_option *popt, *match = NULL, *match2 = NULL;
84
	const struct bsdunzip_option *popt, *match, *match2;
85
	const char *p, *long_prefix = "--";
85
	const char *p, *long_prefix;
86
	size_t optlength;
86
	size_t optlength;
87
	int opt = OPTION_NONE;
87
	int opt;
88
	int required = 0;
88
	int required;
89
89
90
again:
91
	match = NULL;
92
	match2 = NULL;
93
	long_prefix = "--";
94
	opt = OPTION_NONE;
95
	required = 0;
90
	bsdunzip->argument = NULL;
96
	bsdunzip->argument = NULL;
91
97
92
	/* First time through, initialize everything. */
98
	/* First time through, initialize everything. */
Lines 140-146 bsdunzip_getopt(struct bsdunzip *bsdunzip) Link Here
140
		if (opt == '\0') {
146
		if (opt == '\0') {
141
			/* End of this group; recurse to get next option. */
147
			/* End of this group; recurse to get next option. */
142
			bsdunzip->getopt_state = state_next_word;
148
			bsdunzip->getopt_state = state_next_word;
143
			return bsdunzip_getopt(bsdunzip);
149
			goto again;
144
		}
150
		}
145
151
146
		/* Does this option take an argument? */
152
		/* Does this option take an argument? */
(-)b/contrib/libarchive/unzip/test/test_I.c (+13 lines)
Lines 25-36 Link Here
25
 */
25
 */
26
#include "test.h"
26
#include "test.h"
27
27
28
#ifdef HAVE_LOCALE_H
29
#include <locale.h>
30
#endif
31
28
/* Test I arg - file name encoding */
32
/* Test I arg - file name encoding */
29
DEFINE_TEST(test_I)
33
DEFINE_TEST(test_I)
30
{
34
{
31
	const char *reffile = "test_I.zip";
35
	const char *reffile = "test_I.zip";
32
	int r;
36
	int r;
33
37
38
#if HAVE_SETLOCALE
39
	if (NULL == setlocale(LC_ALL, "en_US.UTF-8")) {
40
		skipping("en_US.UTF-8 locale not available on this system.");
41
		return;
42
	}
43
#else
44
	skipping("setlocale() not available on this system.");
45
#endif
46
34
	extract_reference_file(reffile);
47
	extract_reference_file(reffile);
35
	r = systemf("%s -I UTF-8 %s >test.out 2>test.err", testprog, reffile);
48
	r = systemf("%s -I UTF-8 %s >test.out 2>test.err", testprog, reffile);
36
	assertEqualInt(0, r);
49
	assertEqualInt(0, r);
(-)b/lib/libarchive/tests/Makefile (+3 lines)
Lines 188-193 TESTS_SRCS= \ Link Here
188
	test_read_format_ustar_filename.c	\
188
	test_read_format_ustar_filename.c	\
189
	test_read_format_warc.c			\
189
	test_read_format_warc.c			\
190
	test_read_format_xar.c			\
190
	test_read_format_xar.c			\
191
	test_read_format_xar_doublelink.c	\
191
	test_read_format_zip.c			\
192
	test_read_format_zip.c			\
192
	test_read_format_zip_7075_utf8_paths.c	\
193
	test_read_format_zip_7075_utf8_paths.c	\
193
	test_read_format_zip_comment_stored.c	\
194
	test_read_format_zip_comment_stored.c	\
Lines 611-616 ${PACKAGE}FILES+= test_read_format_ustar_filename_cp866.tar.Z.uu Link Here
611
${PACKAGE}FILES+=	test_read_format_ustar_filename_eucjp.tar.Z.uu
612
${PACKAGE}FILES+=	test_read_format_ustar_filename_eucjp.tar.Z.uu
612
${PACKAGE}FILES+=	test_read_format_ustar_filename_koi8r.tar.Z.uu
613
${PACKAGE}FILES+=	test_read_format_ustar_filename_koi8r.tar.Z.uu
613
${PACKAGE}FILES+=	test_read_format_warc.warc.uu
614
${PACKAGE}FILES+=	test_read_format_warc.warc.uu
615
${PACKAGE}FILES+=	test_read_format_xar_doublelink.xar.uu
614
${PACKAGE}FILES+=	test_read_format_zip.zip.uu
616
${PACKAGE}FILES+=	test_read_format_zip.zip.uu
615
${PACKAGE}FILES+=	test_read_format_zip_7075_utf8_paths.zip.uu
617
${PACKAGE}FILES+=	test_read_format_zip_7075_utf8_paths.zip.uu
616
${PACKAGE}FILES+=	test_read_format_zip_7z_deflate.zip.uu
618
${PACKAGE}FILES+=	test_read_format_zip_7z_deflate.zip.uu
Lines 679-684 ${PACKAGE}FILES+= test_splitted_rar_seek_support_aa.uu Link Here
679
${PACKAGE}FILES+=	test_splitted_rar_seek_support_ab.uu
681
${PACKAGE}FILES+=	test_splitted_rar_seek_support_ab.uu
680
${PACKAGE}FILES+=	test_splitted_rar_seek_support_ac.uu
682
${PACKAGE}FILES+=	test_splitted_rar_seek_support_ac.uu
681
${PACKAGE}FILES+=	test_write_disk_appledouble.cpio.gz.uu
683
${PACKAGE}FILES+=	test_write_disk_appledouble.cpio.gz.uu
684
${PACKAGE}FILES+=	test_write_disk_appledouble_zip.zip.uu
682
${PACKAGE}FILES+=	test_write_disk_hfs_compression.tgz.uu
685
${PACKAGE}FILES+=	test_write_disk_hfs_compression.tgz.uu
683
${PACKAGE}FILES+=	test_write_disk_mac_metadata.tar.gz.uu
686
${PACKAGE}FILES+=	test_write_disk_mac_metadata.tar.gz.uu
684
${PACKAGE}FILES+=	test_write_disk_no_hfs_compression.tgz.uu
687
${PACKAGE}FILES+=	test_write_disk_no_hfs_compression.tgz.uu

Return to bug 278588