Permalink
Browse files

Merge branch 'master' of github.com:libarchive/libarchive

  • Loading branch information...
2 parents a1c4c33 + 39df027 commit cfa358a99850cb21b48eff25deffd8c9131b00d8 @kientzle kientzle committed Dec 1, 2012
Showing with 2,814 additions and 469 deletions.
  1. +2 −0 .gitignore
  2. +9 −0 Makefile.am
  3. +10 −7 cpio/cpio.c
  4. +37 −19 cpio/test/main.c
  5. +6 −6 cpio/test/test_basic.c
  6. +2 −2 cpio/test/test_format_newc.c
  7. +1 −1 libarchive/archive_crypto.c
  8. +1 −1 libarchive/archive_match.c
  9. +14 −1 libarchive/archive_options.c
  10. +18 −14 libarchive/archive_read_disk_entry_from_file.c
  11. +2 −1 libarchive/archive_read_disk_posix.c
  12. +4 −4 libarchive/archive_read_disk_windows.c
  13. +1 −1 libarchive/archive_read_extract.c
  14. +2 −2 libarchive/archive_read_open_file.c
  15. +4 −4 libarchive/archive_read_support_filter_gzip.c
  16. +1 −1 libarchive/archive_read_support_filter_lrzip.c
  17. +4 −1 libarchive/archive_read_support_filter_lzop.c
  18. +2 −2 libarchive/archive_read_support_filter_uu.c
  19. +10 −9 libarchive/archive_read_support_format_7zip.c
  20. +15 −14 libarchive/archive_read_support_format_cab.c
  21. +47 −42 libarchive/archive_read_support_format_iso9660.c
  22. +8 −8 libarchive/archive_read_support_format_lha.c
  23. +4 −4 libarchive/archive_read_support_format_mtree.c
  24. +15 −12 libarchive/archive_read_support_format_rar.c
  25. +1 −1 libarchive/archive_read_support_format_raw.c
  26. +11 −11 libarchive/archive_read_support_format_tar.c
  27. +439 −67 libarchive/archive_read_support_format_zip.c
  28. +15 −15 libarchive/archive_string.c
  29. +3 −2 libarchive/archive_util.c
  30. +5 −23 libarchive/archive_write_add_filter_gzip.c
  31. +7 −4 libarchive/archive_write_add_filter_program.c
  32. +1 −1 libarchive/archive_write_add_filter_uuencode.c
  33. +420 −36 libarchive/archive_write_disk_posix.c
  34. +25 −24 libarchive/archive_write_set_format_7zip.c
  35. +41 −40 libarchive/archive_write_set_format_iso9660.c
  36. +5 −4 libarchive/archive_write_set_format_mtree.c
  37. +2 −1 libarchive/archive_write_set_format_pax.c
  38. +6 −6 libarchive/archive_write_set_format_zip.c
  39. +1 −1 libarchive/archive_write_set_options.c
  40. +1 −1 libarchive/filter_fork_windows.c
  41. +4 −0 libarchive/test/CMakeLists.txt
  42. +38 −19 libarchive/test/main.c
  43. +8 −3 libarchive/test/test_acl_freebsd_posix1e.c
  44. +6 −1 libarchive/test/test_acl_nfs4.c
  45. +2 −0 libarchive/test/test_acl_posix1e.c
  46. +18 −0 libarchive/test/test_archive_cmdline.c
  47. +11 −0 libarchive/test/test_archive_read_multiple_data_objects.c
  48. +22 −0 libarchive/test/test_entry.c
  49. +6 −2 libarchive/test/test_fuzz.c
  50. +2 −1 libarchive/test/test_read_disk.c
  51. +2 −1 libarchive/test/test_read_format_cpio_afio.c
  52. +66 −0 libarchive/test/test_read_format_zip_comment_stored.c
  53. +12 −0 libarchive/test/test_read_format_zip_comment_stored_1.zip.uu
  54. +548 −0 libarchive/test/test_read_format_zip_comment_stored_2.zip.uu
  55. +118 −0 libarchive/test/test_read_format_zip_mac_metadata.c
  56. +17 −0 libarchive/test/test_read_format_zip_mac_metadata.zip.uu
  57. +8 −0 libarchive/test/test_read_truncated_filter.c
  58. +3 −2 libarchive/test/test_sparse_basic.c
  59. +210 −0 libarchive/test/test_write_disk_appledouble.c
  60. +12 −0 libarchive/test/test_write_disk_appledouble.cpio.gz.uu
  61. +48 −0 libarchive/test/test_write_disk_hfs_compression.c
  62. +192 −0 libarchive/test/test_write_disk_mac_metadata.c
  63. +14 −0 libarchive/test/test_write_disk_mac_metadata.tar.gz.uu
  64. +12 −2 libarchive/test/test_write_disk_sparse.c
  65. +8 −0 libarchive/test/test_write_filter_bzip2.c
  66. +8 −0 libarchive/test/test_write_filter_gzip.c
  67. +10 −2 libarchive/test/test_write_filter_gzip_timestamp.c
  68. +8 −0 libarchive/test/test_write_filter_lzip.c
  69. +8 −0 libarchive/test/test_write_filter_lzma.c
  70. +8 −0 libarchive/test/test_write_filter_xz.c
  71. +2 −0 libarchive/test/test_write_format_iso9660_empty.c
  72. +6 −0 libarchive/test/test_write_format_iso9660_filename.c
  73. +9 −0 libarchive/test/test_write_format_iso9660_zisofs.c
  74. +3 −3 libarchive/test/test_write_format_mtree_quoted_filename.c
  75. +1 −1 libarchive/test/test_write_format_tar_sparse.c
  76. +11 −1 tar/bsdtar.1
  77. +3 −0 tar/bsdtar.h
  78. +1 −0 tar/creation_set.c
  79. +23 −0 tar/read.c
  80. +38 −19 tar/test/main.c
  81. +2 −2 tar/test/test_copy.c
  82. +6 −1 tar/test/test_option_r.c
  83. +1 −1 tar/test/test_stdio.c
  84. +9 −9 tar/test/test_windows.c
  85. +68 −6 tar/write.c
View
@@ -78,3 +78,5 @@ Testing/
libarchive/libarchive.a
libarchive/libarchive.so
libarchive/libarchive.so.*
+
+.DS_Store
View
@@ -402,7 +402,9 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_ustar_filename.c \
libarchive/test/test_read_format_xar.c \
libarchive/test/test_read_format_zip.c \
+ libarchive/test/test_read_format_zip_comment_stored.c \
libarchive/test/test_read_format_zip_filename.c \
+ libarchive/test/test_read_format_zip_mac_metadata.c \
libarchive/test/test_read_large.c \
libarchive/test/test_read_pax_truncated.c \
libarchive/test/test_read_position.c \
@@ -414,10 +416,12 @@ libarchive_test_SOURCES= \
libarchive/test/test_ustar_filenames.c \
libarchive/test/test_ustar_filename_encoding.c \
libarchive/test/test_write_disk.c \
+ libarchive/test/test_write_disk_appledouble.c \
libarchive/test/test_write_disk_failures.c \
libarchive/test/test_write_disk_hardlink.c \
libarchive/test/test_write_disk_hfs_compression.c \
libarchive/test/test_write_disk_lookup.c \
+ libarchive/test/test_write_disk_mac_metadata.c \
libarchive/test/test_write_disk_no_hfs_compression.c \
libarchive/test/test_write_disk_perms.c \
libarchive/test/test_write_disk_secure.c \
@@ -631,13 +635,16 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_ustar_filename_eucjp.tar.Z.uu \
libarchive/test/test_read_format_ustar_filename_koi8r.tar.Z.uu \
libarchive/test/test_read_format_zip.zip.uu \
+ libarchive/test/test_read_format_zip_comment_stored_1.zip.uu \
+ libarchive/test/test_read_format_zip_comment_stored_2.zip.uu \
libarchive/test/test_read_format_zip_filename_cp866.zip.uu \
libarchive/test/test_read_format_zip_filename_cp932.zip.uu \
libarchive/test/test_read_format_zip_filename_koi8r.zip.uu \
libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \
libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \
libarchive/test/test_read_format_zip_length_at_end.zip.uu \
+ libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
libarchive/test/test_read_format_zip_symlink.zip.uu \
libarchive/test/test_read_format_zip_ux.zip.uu \
libarchive/test/test_read_large_splitted_rar_aa.uu \
@@ -652,7 +659,9 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_splitted_rar_seek_support_aa.uu \
libarchive/test/test_splitted_rar_seek_support_ab.uu \
libarchive/test/test_splitted_rar_seek_support_ac.uu \
+ libarchive/test/test_write_disk_hfs_appledouble.cpio.gz.uu \
libarchive/test/test_write_disk_hfs_compression.tgz.uu \
+ libarchive/test/test_write_disk_mac_metaata.tar.gz.uu \
libarchive/test/test_write_disk_no_hfs_compression.tgz.uu \
libarchive/test/CMakeLists.txt \
libarchive/test/README
View
@@ -840,18 +840,21 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
exit(1);
if (r >= ARCHIVE_WARN && archive_entry_size(entry) > 0 && fd >= 0) {
- bytes_read = read(fd, cpio->buff, cpio->buff_size);
+ bytes_read = read(fd, cpio->buff, (unsigned)cpio->buff_size);
while (bytes_read > 0) {
- r = archive_write_data(cpio->archive,
+ ssize_t bytes_write;
+ bytes_write = archive_write_data(cpio->archive,
cpio->buff, bytes_read);
- if (r < 0)
+ if (bytes_write < 0)
lafe_errc(1, archive_errno(cpio->archive),
"%s", archive_error_string(cpio->archive));
- if (r < bytes_read) {
+ if (bytes_write < bytes_read) {
lafe_warnc(0,
- "Truncated write; file may have grown while being archived.");
+ "Truncated write; file may have "
+ "grown while being archived.");
}
- bytes_read = read(fd, cpio->buff, cpio->buff_size);
+ bytes_read = read(fd, cpio->buff,
+ (unsigned)cpio->buff_size);
}
}
@@ -1023,7 +1026,7 @@ extract_data(struct archive *ar, struct archive *aw)
"%s", archive_error_string(ar));
exit(1);
}
- r = archive_write_data_block(aw, block, size, offset);
+ r = (int)archive_write_data_block(aw, block, size, offset);
if (r != ARCHIVE_OK) {
lafe_warnc(archive_errno(aw),
"%s", archive_error_string(aw));
View
@@ -624,8 +624,8 @@ assertion_equal_string(const char *file, int line,
if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
return (1);
failure_start(file, line, "%s != %s", e1, e2);
- l1 = strlen(e1);
- l2 = strlen(e2);
+ l1 = (int)strlen(e1);
+ l2 = (int)strlen(e2);
if (l1 < l2)
l1 = l2;
strdump(e1, v1, l1, utf8);
@@ -748,6 +748,8 @@ assertion_equal_mem(const char *file, int line,
assertion_count(file, line);
if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
return (1);
+ if (v1 == NULL || v2 == NULL)
+ return (0);
failure_start(file, line, "%s != %s", e1, e2);
logprintf(" size %s = %d\n", ld, (int)l);
@@ -847,8 +849,8 @@ assertion_equal_file(const char *filename, int line, const char *fn1, const char
return (0);
}
for (;;) {
- n1 = fread(buff1, 1, sizeof(buff1), f1);
- n2 = fread(buff2, 1, sizeof(buff2), f2);
+ n1 = (int)fread(buff1, 1, sizeof(buff1), f1);
+ n2 = (int)fread(buff2, 1, sizeof(buff2), f2);
if (n1 != n2)
break;
if (n1 == 0 && n2 == 0) {
@@ -922,7 +924,7 @@ assertion_file_contents(const char *filename, int line, const void *buff, int s,
return (0);
}
contents = malloc(s * 2);
- n = fread(contents, 1, s * 2, f);
+ n = (int)fread(contents, 1, s * 2, f);
fclose(f);
if (n == s && memcmp(buff, contents, s) == 0) {
free(contents);
@@ -958,9 +960,9 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c
failure_finish(NULL);
return (0);
}
- s = strlen(buff);
+ s = (int)strlen(buff);
contents = malloc(s * 2 + 128);
- n = fread(contents, 1, s * 2 + 128 - 1, f);
+ n = (int)fread(contents, 1, s * 2 + 128 - 1, f);
if (n >= 0)
contents[n] = '\0';
fclose(f);
@@ -1011,8 +1013,8 @@ assertion_file_contains_lines_any_order(const char *file, int line,
char *buff;
size_t buff_size;
size_t expected_count, actual_count, i, j;
- char **expected;
- char *p, **actual;
+ char **expected = NULL;
+ char *p, **actual = NULL;
char c;
int expected_failure = 0, actual_failure = 0;
@@ -1025,14 +1027,21 @@ assertion_file_contains_lines_any_order(const char *file, int line,
return (0);
}
- /* Make a copy of the provided lines and count up the expected file size. */
- expected_count = 0;
+ /* Make a copy of the provided lines and count up the expected
+ * file size. */
for (i = 0; lines[i] != NULL; ++i) {
}
expected_count = i;
- expected = malloc(sizeof(char *) * expected_count);
- for (i = 0; lines[i] != NULL; ++i) {
- expected[i] = strdup(lines[i]);
+ if (expected_count) {
+ expected = malloc(sizeof(char *) * expected_count);
+ if (expected == NULL) {
+ failure_start(pathname, line, "Can't allocate memory");
+ failure_finish(NULL);
+ return (0);
+ }
+ for (i = 0; lines[i] != NULL; ++i) {
+ expected[i] = strdup(lines[i]);
+ }
}
/* Break the file into lines */
@@ -1044,11 +1053,19 @@ assertion_file_contains_lines_any_order(const char *file, int line,
++actual_count;
c = *p;
}
- actual = malloc(sizeof(char *) * actual_count);
- for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
- if (*p != '\0') {
- actual[j] = p;
- ++j;
+ if (actual_count) {
+ actual = calloc(sizeof(char *), actual_count);
+ if (actual == NULL) {
+ failure_start(pathname, line, "Can't allocate memory");
+ failure_finish(NULL);
+ free(expected);
+ return (0);
+ }
+ for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
+ if (*p != '\0') {
+ actual[j] = p;
+ ++j;
+ }
}
}
@@ -2762,6 +2779,7 @@ main(int argc, char **argv)
if (test_num < 0) {
printf("*** INVALID Test %s\n", *argv);
free(refdir_alloc);
+ free(testprogdir);
usage(progname);
return (1);
}
View
@@ -148,7 +148,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: file: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
/* hardlink to above file. */
assertMakeHardlink("linkfile", "file");
@@ -157,7 +157,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: linkfile: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
/* Symlink to above file. */
if (canSymlink()) {
@@ -167,7 +167,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: symlink: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
}
/* Another file with different permissions. */
@@ -177,7 +177,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: file2: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
/* Directory. */
assertMakeDir("dir", 0775);
@@ -186,8 +186,8 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: dir: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
- strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
+ strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
/* All done. */
fclose(filelist);
@@ -157,9 +157,9 @@ DEFINE_TEST(test_format_newc)
/* Verify that nothing went to stderr. */
if (canSymlink()) {
- strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
+ strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
} else {
- strncat(result, "1 block\n", sizeof(result) - strlen(result));
+ strncat(result, "1 block\n", sizeof(result) - strlen(result) -1);
}
assertTextFileContents(result, "newc.err");
@@ -90,7 +90,7 @@ win_crypto_Update(Digest_CTX *ctx, const unsigned char *buf, size_t len)
static int
win_crypto_Final(unsigned char *buf, size_t bufsize, Digest_CTX *ctx)
{
- DWORD siglen = bufsize;
+ DWORD siglen = (DWORD)bufsize;
if (!ctx->valid)
return (ARCHIVE_FAILED);
@@ -1712,7 +1712,7 @@ match_owner_id(struct id_array *ids, int64_t id)
unsigned b, m, t;
t = 0;
- b = ids->count;
+ b = (unsigned)ids->count;
while (t < b) {
m = (t + b)>>1;
if (ids->ids[m] == id)
@@ -87,14 +87,16 @@ _archive_set_either_option(struct archive *a, const char *m, const char *o, cons
if (r2 == ARCHIVE_FATAL)
return (ARCHIVE_FATAL);
+ if (r2 == ARCHIVE_WARN - 1)
+ return r1;
return r1 > r2 ? r1 : r2;
}
int
_archive_set_options(struct archive *a, const char *options,
int magic, const char *fn, option_handler use_option)
{
- int allok = 1, anyok = 0, r;
+ int allok = 1, anyok = 0, ignore_mod_err = 0, r;
char *data;
const char *s, *mod, *opt, *val;
@@ -111,6 +113,15 @@ _archive_set_options(struct archive *a, const char *options,
mod = opt = val = NULL;
parse_option(&s, &mod, &opt, &val);
+ if (mod == NULL && opt != NULL &&
+ strcmp("__ignore_wrong_module_name__", opt) == 0) {
+ /* Ignore module name error */
+ if (val != NULL) {
+ ignore_mod_err = 1;
+ anyok = 1;
+ }
+ continue;
+ }
r = use_option(a, mod, opt, val);
if (r == ARCHIVE_FATAL) {
@@ -122,6 +133,8 @@ _archive_set_options(struct archive *a, const char *options,
return (ARCHIVE_FAILED);
}
if (r == ARCHIVE_WARN - 1) {
+ if (ignore_mod_err)
+ continue;
/* The module name is wrong. */
archive_set_error(a, ARCHIVE_ERRNO_MISC,
"Unknown module name: `%s'", mod);
@@ -294,7 +294,8 @@ setup_mac_metadata(struct archive_read_disk *a,
int ret = ARCHIVE_OK;
void *buff;
int have_attrs;
- const char *name, *tempdir, *tempfile = NULL;
+ const char *name, *tempdir;
+ struct archive_string tempfile;
(void)fd; /* UNUSED */
name = archive_entry_sourcepath(entry);
@@ -329,26 +330,28 @@ setup_mac_metadata(struct archive_read_disk *a,
tempdir = getenv("TMPDIR");
if (tempdir == NULL)
tempdir = _PATH_TMP;
- tempfile = tempnam(tempdir, "tar.md.");
+ archive_string_init(&tempfile);
+ archive_strcpy(&tempfile, tempdir);
+ archive_strcat(&tempfile, "tar.md.XXXXXX");
+ tempfd = mkstemp(tempfile.s);
+ if (tempfd < 0) {
+ archive_set_error(&a->archive, errno,
+ "Could not open extended attribute file");
+ ret = ARCHIVE_WARN;
+ goto cleanup;
+ }
+ __archive_ensure_cloexec_flag(tempfd);
/* XXX I wish copyfile() could pack directly to a memory
* buffer; that would avoid the temp file here. For that
* matter, it would be nice if fcopyfile() actually worked,
* that would reduce the many open/close races here. */
- if (copyfile(name, tempfile, 0, copyfile_flags | COPYFILE_PACK)) {
+ if (copyfile(name, tempfile.s, 0, copyfile_flags | COPYFILE_PACK)) {
archive_set_error(&a->archive, errno,
"Could not pack extended attributes");
ret = ARCHIVE_WARN;
goto cleanup;
}
- tempfd = open(tempfile, O_RDONLY | O_CLOEXEC);
- if (tempfd < 0) {
- archive_set_error(&a->archive, errno,
- "Could not open extended attribute file");
- ret = ARCHIVE_WARN;
- goto cleanup;
- }
- __archive_ensure_cloexec_flag(tempfd);
if (fstat(tempfd, &copyfile_stat)) {
archive_set_error(&a->archive, errno,
"Could not check size of extended attributes");
@@ -371,10 +374,11 @@ setup_mac_metadata(struct archive_read_disk *a,
archive_entry_copy_mac_metadata(entry, buff, copyfile_stat.st_size);
cleanup:
- if (tempfd >= 0)
+ if (tempfd >= 0) {
close(tempfd);
- if (tempfile != NULL)
- unlink(tempfile);
+ unlink(tempfile.s);
+ }
+ archive_string_free(&tempfile);
return (ret);
}
Oops, something went wrong.

0 comments on commit cfa358a

Please sign in to comment.