1 /*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * Copyright (c) 2011 Michihiro NAKAJIMA 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 #include "test.h" 27 __FBSDID("$FreeBSD$"); 28 29 #define __LIBARCHIVE_BUILD 30 #include <archive_crc32.h> 31 32 static 33 int extract_one(struct archive* a, struct archive_entry* ae, uint32_t crc) 34 { 35 la_ssize_t fsize, bytes_read; 36 uint8_t* buf; 37 int ret = 1; 38 uint32_t computed_crc; 39 40 fsize = (la_ssize_t) archive_entry_size(ae); 41 buf = malloc(fsize); 42 if(buf == NULL) 43 return 1; 44 45 bytes_read = archive_read_data(a, buf, fsize); 46 if(bytes_read != fsize) { 47 assertEqualInt(bytes_read, fsize); 48 goto fn_exit; 49 } 50 51 computed_crc = crc32(0, buf, fsize); 52 assertEqualInt(computed_crc, crc); 53 ret = 0; 54 55 fn_exit: 56 free(buf); 57 return ret; 58 } 59 60 static 61 int extract_one_using_blocks(struct archive* a, int block_size, uint32_t crc) 62 { 63 uint8_t* buf; 64 int ret = 1; 65 uint32_t computed_crc = 0; 66 la_ssize_t bytes_read; 67 68 buf = malloc(block_size); 69 if(buf == NULL) 70 return 1; 71 72 while(1) { 73 bytes_read = archive_read_data(a, buf, block_size); 74 if(bytes_read == ARCHIVE_RETRY) 75 continue; 76 else if(bytes_read == 0) 77 break; 78 else if(bytes_read < 0) { 79 /* If we're here, it means the decompressor has failed 80 * to properly decode test file. */ 81 assertA(0); 82 ret = 1; 83 goto fn_exit; 84 } else { 85 /* ok */ 86 } 87 88 computed_crc = crc32(computed_crc, buf, bytes_read); 89 } 90 91 assertEqualInt(computed_crc, crc); 92 ret = 0; 93 94 fn_exit: 95 free(buf); 96 return ret; 97 } 98 99 /* 100 * The reference file for this has been manually tweaked so that: 101 * * file2 has length-at-end but file1 does not 102 * * file2 has an invalid CRC 103 */ 104 static void 105 verify_basic(struct archive *a, int seek_checks) 106 { 107 struct archive_entry *ae; 108 char *buff[128]; 109 const void *pv; 110 size_t s; 111 int64_t o; 112 113 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 114 assertEqualString("ZIP 1.0 (uncompressed)", archive_format_name(a)); 115 assertEqualString("dir/", archive_entry_pathname(ae)); 116 assertEqualInt(1179604249, archive_entry_mtime(ae)); 117 assertEqualInt(0, archive_entry_size(ae)); 118 if (seek_checks) 119 assertEqualInt(AE_IFDIR | 0755, archive_entry_mode(ae)); 120 assertEqualInt(archive_entry_is_encrypted(ae), 0); 121 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 122 assertEqualIntA(a, ARCHIVE_EOF, 123 archive_read_data_block(a, &pv, &s, &o)); 124 assertEqualInt((int)s, 0); 125 126 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 127 assertEqualString("ZIP 2.0 (deflation)", archive_format_name(a)); 128 assertEqualString("file1", archive_entry_pathname(ae)); 129 assertEqualInt(1179604289, archive_entry_mtime(ae)); 130 if (seek_checks) 131 assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae)); 132 assertEqualInt(18, archive_entry_size(ae)); 133 assertEqualInt(archive_entry_is_encrypted(ae), 0); 134 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 135 failure("archive_read_data() returns number of bytes read"); 136 if (archive_zlib_version() != NULL) { 137 assertEqualInt(18, archive_read_data(a, buff, 19)); 138 assertEqualMem(buff, "hello\nhello\nhello\n", 18); 139 } else { 140 assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19)); 141 assertEqualString(archive_error_string(a), 142 "Unsupported ZIP compression method (8: deflation)"); 143 assert(archive_errno(a) != 0); 144 } 145 146 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 147 assertEqualString("ZIP 2.0 (deflation)", archive_format_name(a)); 148 assertEqualString("file2", archive_entry_pathname(ae)); 149 assertEqualInt(1179605932, archive_entry_mtime(ae)); 150 assertEqualInt(archive_entry_is_encrypted(ae), 0); 151 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 152 if (seek_checks) { 153 assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae)); 154 } 155 assert(archive_entry_size_is_set(ae)); 156 assertEqualInt(18, archive_entry_size(ae)); 157 if (archive_zlib_version() != NULL) { 158 failure("file2 has a bad CRC, so read should fail and not change buff"); 159 memset(buff, 'a', 19); 160 assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19)); 161 assertEqualMem(buff, "aaaaaaaaaaaaaaaaaaa", 19); 162 } else { 163 assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19)); 164 assertEqualString(archive_error_string(a), 165 "Unsupported ZIP compression method (8: deflation)"); 166 assert(archive_errno(a) != 0); 167 } 168 assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); 169 assertEqualString("ZIP 2.0 (deflation)", archive_format_name(a)); 170 /* Verify the number of files read. */ 171 failure("the archive file has three files"); 172 assertEqualInt(3, archive_file_count(a)); 173 assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); 174 assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a)); 175 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 176 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 177 } 178 179 static void 180 test_basic(void) 181 { 182 const char *refname = "test_read_format_zip.zip"; 183 struct archive *a; 184 char *p; 185 size_t s; 186 187 extract_reference_file(refname); 188 189 /* Verify with seeking reader. */ 190 assert((a = archive_read_new()) != NULL); 191 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); 192 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 193 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240)); 194 verify_basic(a, 1); 195 196 /* Verify with streaming reader. */ 197 p = slurpfile(&s, "%s", refname); 198 assert((a = archive_read_new()) != NULL); 199 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); 200 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 201 assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 31)); 202 verify_basic(a, 0); 203 free(p); 204 } 205 206 /* 207 * Read Info-ZIP New Unix Extra Field 0x7875 "ux". 208 * Currently stores Unix UID/GID up to 32 bits. 209 */ 210 static void 211 verify_info_zip_ux(struct archive *a, int seek_checks) 212 { 213 struct archive_entry *ae; 214 char *buff[128]; 215 216 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 217 assertEqualString("file1", archive_entry_pathname(ae)); 218 assertEqualInt(1300668680, archive_entry_mtime(ae)); 219 assertEqualInt(18, archive_entry_size(ae)); 220 assertEqualInt(archive_entry_is_encrypted(ae), 0); 221 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 222 if (seek_checks) 223 assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae)); 224 failure("zip reader should read Info-ZIP New Unix Extra Field"); 225 assertEqualInt(1001, archive_entry_uid(ae)); 226 assertEqualInt(1001, archive_entry_gid(ae)); 227 if (archive_zlib_version() != NULL) { 228 failure("archive_read_data() returns number of bytes read"); 229 assertEqualInt(18, archive_read_data(a, buff, 19)); 230 assertEqualMem(buff, "hello\nhello\nhello\n", 18); 231 } else { 232 assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19)); 233 assertEqualString(archive_error_string(a), 234 "Unsupported ZIP compression method (8: deflation)"); 235 assert(archive_errno(a) != 0); 236 } 237 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 238 239 /* Verify the number of files read. */ 240 failure("the archive file has just one file"); 241 assertEqualInt(1, archive_file_count(a)); 242 243 assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); 244 assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a)); 245 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 246 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 247 } 248 249 static void 250 test_info_zip_ux(void) 251 { 252 const char *refname = "test_read_format_zip_ux.zip"; 253 struct archive *a; 254 char *p; 255 size_t s; 256 257 extract_reference_file(refname); 258 259 /* Verify with seeking reader. */ 260 assert((a = archive_read_new()) != NULL); 261 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); 262 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 263 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240)); 264 verify_info_zip_ux(a, 1); 265 266 /* Verify with streaming reader. */ 267 p = slurpfile(&s, "%s", refname); 268 assert((a = archive_read_new()) != NULL); 269 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); 270 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 271 assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108)); 272 verify_info_zip_ux(a, 0); 273 free(p); 274 } 275 276 /* 277 * Verify that test_read_extract correctly works with 278 * Zip entries that use length-at-end. 279 */ 280 static void 281 verify_extract_length_at_end(struct archive *a, int seek_checks) 282 { 283 struct archive_entry *ae; 284 285 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 286 287 assertEqualInt(archive_entry_is_encrypted(ae), 0); 288 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 289 assertEqualString("hello.txt", archive_entry_pathname(ae)); 290 if (seek_checks) { 291 assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae)); 292 assert(archive_entry_size_is_set(ae)); 293 assertEqualInt(6, archive_entry_size(ae)); 294 } else { 295 assert(!archive_entry_size_is_set(ae)); 296 assertEqualInt(0, archive_entry_size(ae)); 297 } 298 299 if (archive_zlib_version() != NULL) { 300 assertEqualIntA(a, ARCHIVE_OK, archive_read_extract(a, ae, 0)); 301 assertFileContents("hello\x0A", 6, "hello.txt"); 302 } else { 303 assertEqualIntA(a, ARCHIVE_FAILED, archive_read_extract(a, ae, 0)); 304 assertEqualString(archive_error_string(a), 305 "Unsupported ZIP compression method (8: deflation)"); 306 assert(archive_errno(a) != 0); 307 } 308 309 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 310 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 311 } 312 313 static void 314 test_extract_length_at_end(void) 315 { 316 const char *refname = "test_read_format_zip_length_at_end.zip"; 317 char *p; 318 size_t s; 319 struct archive *a; 320 321 extract_reference_file(refname); 322 323 /* Verify extraction with seeking reader. */ 324 assert((a = archive_read_new()) != NULL); 325 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); 326 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 327 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240)); 328 verify_extract_length_at_end(a, 1); 329 330 /* Verify extraction with streaming reader. */ 331 p = slurpfile(&s, "%s", refname); 332 assert((a = archive_read_new()) != NULL); 333 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); 334 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); 335 assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108)); 336 verify_extract_length_at_end(a, 0); 337 free(p); 338 } 339 340 static void 341 test_symlink(void) 342 { 343 const char *refname = "test_read_format_zip_symlink.zip"; 344 char *p; 345 size_t s; 346 struct archive *a; 347 struct archive_entry *ae; 348 349 extract_reference_file(refname); 350 p = slurpfile(&s, "%s", refname); 351 352 /* Symlinks can only be extracted with the seeking reader. */ 353 assert((a = archive_read_new()) != NULL); 354 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 355 assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 1)); 356 357 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 358 assertEqualString("file", archive_entry_pathname(ae)); 359 assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); 360 assertEqualInt(archive_entry_is_encrypted(ae), 0); 361 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 362 363 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 364 assertEqualString("symlink", archive_entry_pathname(ae)); 365 assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); 366 assertEqualInt(0, archive_entry_size(ae)); 367 assertEqualString("file", archive_entry_symlink(ae)); 368 assertEqualInt(archive_entry_is_encrypted(ae), 0); 369 assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 370 371 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 372 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 373 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 374 375 free(p); 376 } 377 378 DEFINE_TEST(test_read_format_zip) 379 { 380 test_basic(); 381 test_info_zip_ux(); 382 test_extract_length_at_end(); 383 test_symlink(); 384 } 385 386 DEFINE_TEST(test_read_format_zip_ppmd_one_file) 387 { 388 const char *refname = "test_read_format_zip_ppmd8.zipx"; 389 struct archive *a; 390 struct archive_entry *ae; 391 392 extract_reference_file(refname); 393 394 assert((a = archive_read_new()) != NULL); 395 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 396 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 397 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 398 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 399 assertEqualString("vimrc", archive_entry_pathname(ae)); 400 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 401 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 402 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 403 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 404 } 405 406 DEFINE_TEST(test_read_format_zip_ppmd_one_file_blockread) 407 { 408 const char *refname = "test_read_format_zip_ppmd8.zipx"; 409 struct archive *a; 410 struct archive_entry *ae; 411 412 extract_reference_file(refname); 413 414 assert((a = archive_read_new()) != NULL); 415 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 416 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 417 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 418 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 419 assertEqualString("vimrc", archive_entry_pathname(ae)); 420 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0xBA8E3BAA)); 421 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 422 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 423 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 424 } 425 426 DEFINE_TEST(test_read_format_zip_ppmd_multi) 427 { 428 const char *refname = "test_read_format_zip_ppmd8_multi.zipx"; 429 struct archive *a; 430 struct archive_entry *ae; 431 432 extract_reference_file(refname); 433 434 assert((a = archive_read_new()) != NULL); 435 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 436 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 437 438 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 439 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 440 assertEqualString("smartd.conf", archive_entry_pathname(ae)); 441 assertEqualIntA(a, 0, extract_one(a, ae, 0x8DD7379E)); 442 443 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 444 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 445 assertEqualString("ts.conf", archive_entry_pathname(ae)); 446 assertEqualIntA(a, 0, extract_one(a, ae, 0x7AE59B31)); 447 448 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 449 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 450 assertEqualString("vimrc", archive_entry_pathname(ae)); 451 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 452 453 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 454 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 455 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 456 } 457 458 DEFINE_TEST(test_read_format_zip_ppmd_multi_blockread) 459 { 460 const char *refname = "test_read_format_zip_ppmd8_multi.zipx"; 461 struct archive *a; 462 struct archive_entry *ae; 463 464 extract_reference_file(refname); 465 466 assert((a = archive_read_new()) != NULL); 467 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 468 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 469 470 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 471 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 472 assertEqualString("smartd.conf", archive_entry_pathname(ae)); 473 assertEqualIntA(a, 0, extract_one_using_blocks(a, 12, 0x8DD7379E)); 474 475 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 476 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 477 assertEqualString("ts.conf", archive_entry_pathname(ae)); 478 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0x7AE59B31)); 479 480 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 481 assertEqualString("ZIP 6.3 (ppmd-1)", archive_format_name(a)); 482 assertEqualString("vimrc", archive_entry_pathname(ae)); 483 assertEqualIntA(a, 0, extract_one_using_blocks(a, 14, 0xBA8E3BAA)); 484 485 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 486 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 487 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 488 } 489 490 DEFINE_TEST(test_read_format_zip_lzma_one_file) 491 { 492 const char *refname = "test_read_format_zip_lzma.zipx"; 493 struct archive *a; 494 struct archive_entry *ae; 495 496 assert((a = archive_read_new()) != NULL); 497 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 498 skipping("lzma reading not fully supported on this platform"); 499 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 500 return; 501 } 502 extract_reference_file(refname); 503 504 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 505 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 506 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 507 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 508 assertEqualString("vimrc", archive_entry_pathname(ae)); 509 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 510 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 511 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 512 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 513 } 514 515 DEFINE_TEST(test_read_format_zip_lzma_one_file_blockread) 516 { 517 const char *refname = "test_read_format_zip_lzma.zipx"; 518 struct archive *a; 519 struct archive_entry *ae; 520 521 assert((a = archive_read_new()) != NULL); 522 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 523 skipping("lzma reading not fully supported on this platform"); 524 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 525 return; 526 } 527 extract_reference_file(refname); 528 529 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 530 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 531 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 532 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 533 assertEqualString("vimrc", archive_entry_pathname(ae)); 534 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0xBA8E3BAA)); 535 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 536 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 537 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 538 } 539 540 DEFINE_TEST(test_read_format_zip_lzma_multi) 541 { 542 const char *refname = "test_read_format_zip_lzma_multi.zipx"; 543 struct archive *a; 544 struct archive_entry *ae; 545 546 assert((a = archive_read_new()) != NULL); 547 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 548 skipping("lzma reading not fully supported on this platform"); 549 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 550 return; 551 } 552 extract_reference_file(refname); 553 554 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 555 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 556 557 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 558 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 559 assertEqualString("smartd.conf", archive_entry_pathname(ae)); 560 assertEqualIntA(a, 0, extract_one(a, ae, 0x8DD7379E)); 561 562 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 563 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 564 assertEqualString("ts.conf", archive_entry_pathname(ae)); 565 assertEqualIntA(a, 0, extract_one(a, ae, 0x7AE59B31)); 566 567 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 568 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 569 assertEqualString("vimrc", archive_entry_pathname(ae)); 570 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 571 572 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 573 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 574 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 575 } 576 577 DEFINE_TEST(test_read_format_zip_lzma_multi_blockread) 578 { 579 const char *refname = "test_read_format_zip_lzma_multi.zipx"; 580 struct archive *a; 581 struct archive_entry *ae; 582 583 assert((a = archive_read_new()) != NULL); 584 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 585 skipping("lzma reading not fully supported on this platform"); 586 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 587 return; 588 } 589 extract_reference_file(refname); 590 591 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 592 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 593 594 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 595 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 596 assertEqualString("smartd.conf", archive_entry_pathname(ae)); 597 assertEqualIntA(a, 0, extract_one_using_blocks(a, 12, 0x8DD7379E)); 598 599 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 600 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 601 assertEqualString("ts.conf", archive_entry_pathname(ae)); 602 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0x7AE59B31)); 603 604 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 605 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 606 assertEqualString("vimrc", archive_entry_pathname(ae)); 607 assertEqualIntA(a, 0, extract_one_using_blocks(a, 14, 0xBA8E3BAA)); 608 609 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 610 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 611 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 612 } 613 614 615 DEFINE_TEST(test_read_format_zip_bzip2_one_file) 616 { 617 const char *refname = "test_read_format_zip_bzip2.zipx"; 618 struct archive *a; 619 struct archive_entry *ae; 620 621 assert((a = archive_read_new()) != NULL); 622 if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) { 623 skipping("bzip2 is not fully supported on this platform"); 624 archive_read_close(a); 625 return; 626 } 627 extract_reference_file(refname); 628 629 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 630 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 631 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 632 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 633 assertEqualString("vimrc", archive_entry_pathname(ae)); 634 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 635 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 636 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 637 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 638 } 639 640 DEFINE_TEST(test_read_format_zip_bzip2_one_file_blockread) 641 { 642 const char *refname = "test_read_format_zip_bzip2.zipx"; 643 struct archive *a; 644 struct archive_entry *ae; 645 646 assert((a = archive_read_new()) != NULL); 647 if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) { 648 skipping("bzip2 is not fully supported on this platform"); 649 archive_read_close(a); 650 return; 651 } 652 extract_reference_file(refname); 653 654 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 655 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 656 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 657 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 658 assertEqualString("vimrc", archive_entry_pathname(ae)); 659 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0xBA8E3BAA)); 660 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 661 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 662 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 663 } 664 665 DEFINE_TEST(test_read_format_zip_bzip2_multi) 666 { 667 const char *refname = "test_read_format_zip_bzip2_multi.zipx"; 668 struct archive *a; 669 struct archive_entry *ae; 670 671 assert((a = archive_read_new()) != NULL); 672 if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) { 673 skipping("bzip2 is not fully supported on this platform"); 674 archive_read_close(a); 675 return; 676 } 677 extract_reference_file(refname); 678 679 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 680 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 681 682 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 683 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 684 assertEqualString("smartd.conf", archive_entry_pathname(ae)); 685 assertEqualIntA(a, 0, extract_one(a, ae, 0x8DD7379E)); 686 687 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 688 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 689 assertEqualString("ts.conf", archive_entry_pathname(ae)); 690 assertEqualIntA(a, 0, extract_one(a, ae, 0x7AE59B31)); 691 692 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 693 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 694 assertEqualString("vimrc", archive_entry_pathname(ae)); 695 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 696 697 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 698 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 699 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 700 } 701 702 DEFINE_TEST(test_read_format_zip_bzip2_multi_blockread) 703 { 704 const char *refname = "test_read_format_zip_bzip2_multi.zipx"; 705 struct archive *a; 706 struct archive_entry *ae; 707 708 assert((a = archive_read_new()) != NULL); 709 if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) { 710 skipping("bzip2 is not fully supported on this platform"); 711 archive_read_close(a); 712 return; 713 } 714 extract_reference_file(refname); 715 716 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 717 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 718 719 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 720 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 721 assertEqualString("smartd.conf", archive_entry_pathname(ae)); 722 assertEqualIntA(a, 0, extract_one_using_blocks(a, 12, 0x8DD7379E)); 723 724 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 725 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 726 assertEqualString("ts.conf", archive_entry_pathname(ae)); 727 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0x7AE59B31)); 728 729 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 730 assertEqualString("ZIP 4.6 (bzip)", archive_format_name(a)); 731 assertEqualString("vimrc", archive_entry_pathname(ae)); 732 assertEqualIntA(a, 0, extract_one_using_blocks(a, 14, 0xBA8E3BAA)); 733 734 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 735 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 736 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 737 } 738 739 DEFINE_TEST(test_read_format_zip_xz_multi) 740 { 741 const char *refname = "test_read_format_zip_xz_multi.zipx"; 742 struct archive *a; 743 struct archive_entry *ae; 744 745 assert((a = archive_read_new()) != NULL); 746 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 747 skipping("lzma reading not fully supported on this platform"); 748 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 749 return; 750 } 751 extract_reference_file(refname); 752 753 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 754 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 755 756 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 757 assertEqualString("ZIP 2.0 (xz)", archive_format_name(a)); 758 assertEqualString("bash.bashrc", archive_entry_pathname(ae)); 759 assertEqualIntA(a, 0, extract_one(a, ae, 0xF751B8C9)); 760 761 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 762 assertEqualString("ZIP 2.0 (xz)", archive_format_name(a)); 763 assertEqualString("pacman.conf", archive_entry_pathname(ae)); 764 assertEqualIntA(a, 0, extract_one(a, ae, 0xB20B7F88)); 765 766 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 767 assertEqualString("ZIP 2.0 (xz)", archive_format_name(a)); 768 assertEqualString("profile", archive_entry_pathname(ae)); 769 assertEqualIntA(a, 0, extract_one(a, ae, 0x2329F054)); 770 771 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 772 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 773 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 774 } 775 776 DEFINE_TEST(test_read_format_zip_xz_multi_blockread) 777 { 778 const char *refname = "test_read_format_zip_xz_multi.zipx"; 779 struct archive *a; 780 struct archive_entry *ae; 781 782 assert((a = archive_read_new()) != NULL); 783 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 784 skipping("lzma reading not fully supported on this platform"); 785 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 786 return; 787 } 788 extract_reference_file(refname); 789 790 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 791 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 792 793 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 794 assertEqualString("ZIP 2.0 (xz)", archive_format_name(a)); 795 assertEqualString("bash.bashrc", archive_entry_pathname(ae)); 796 assertEqualIntA(a, 0, extract_one_using_blocks(a, 12, 0xF751B8C9)); 797 798 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 799 assertEqualString("ZIP 2.0 (xz)", archive_format_name(a)); 800 assertEqualString("pacman.conf", archive_entry_pathname(ae)); 801 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0xB20B7F88)); 802 803 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 804 assertEqualString("ZIP 2.0 (xz)", archive_format_name(a)); 805 assertEqualString("profile", archive_entry_pathname(ae)); 806 assertEqualIntA(a, 0, extract_one_using_blocks(a, 14, 0x2329F054)); 807 808 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 809 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 810 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 811 } 812 813 DEFINE_TEST(test_read_format_zip_ppmd8_crash_1) 814 { 815 const char *refname = "test_read_format_zip_ppmd8_crash_2.zipx"; 816 struct archive *a; 817 struct archive_entry *ae; 818 char buf[64]; 819 820 extract_reference_file(refname); 821 822 assert((a = archive_read_new()) != NULL); 823 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 824 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 100)); 825 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 826 827 /* This file shouldn't be properly decompressed, because it's invalid. 828 * However, unpacker should return an error during unpacking. Without the 829 * proper fix, the unpacker was entering an unlimited loop. */ 830 assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, buf, 1)); 831 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 832 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 833 } 834 835 DEFINE_TEST(test_read_format_zip_bz2_hang_on_invalid) 836 { 837 const char *refname = "test_read_format_zip_bz2_hang.zip"; 838 struct archive *a; 839 struct archive_entry *ae; 840 char buf[8]; 841 842 assert((a = archive_read_new()) != NULL); 843 if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) { 844 skipping("bzip2 is not fully supported on this platform"); 845 archive_read_close(a); 846 return; 847 } 848 extract_reference_file(refname); 849 850 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 851 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 852 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 853 854 /* The file `refname` is invalid in this case, so this call should fail. 855 * But it shouldn't crash. */ 856 assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, buf, 64)); 857 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 858 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 859 } 860 861 DEFINE_TEST(test_read_format_zip_ppmd8_crash_2) 862 { 863 const char *refname = "test_read_format_zip_ppmd8_crash_2.zipx"; 864 struct archive *a; 865 struct archive_entry *ae; 866 char buf[64]; 867 868 extract_reference_file(refname); 869 870 assert((a = archive_read_new()) != NULL); 871 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 872 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 873 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 874 875 /* The file `refname` is invalid in this case, so this call should fail. 876 * But it shouldn't crash. */ 877 assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, buf, 64)); 878 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 879 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 880 } 881 882 DEFINE_TEST(test_read_format_zip_lzma_alone_leak) 883 { 884 const char *refname = "test_read_format_zip_lzma_alone_leak.zipx"; 885 struct archive *a; 886 struct archive_entry *ae; 887 char buf[64]; 888 889 /* OSSFuzz #14470 sample file. */ 890 extract_reference_file(refname); 891 892 assert((a = archive_read_new()) != NULL); 893 if(ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 894 skipping("lzma reading is not fully supported on this platform"); 895 archive_read_close(a); 896 return; 897 } 898 899 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 900 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 901 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 902 903 /* Extraction of this file should fail, because the sample file is invalid. 904 * But it shouldn't crash. */ 905 assertEqualIntA(a, ARCHIVE_FAILED, archive_read_data(a, buf, sizeof(buf))); 906 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 907 908 /* Extraction of this file should fail, because the sample file is invalid. 909 * But it shouldn't crash. */ 910 assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, buf, sizeof(buf))); 911 912 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 913 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 914 915 /* This testcase shouldn't produce any memory leaks. When running test 916 * suite under Valgrind or ASan, the test runner won't return with 917 * exit code 0 in case if a memory leak. */ 918 } 919 920 DEFINE_TEST(test_read_format_zip_lzma_stream_end) 921 { 922 const char *refname = "test_read_format_zip_lzma_stream_end.zipx"; 923 struct archive *a; 924 struct archive_entry *ae; 925 926 assert((a = archive_read_new()) != NULL); 927 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 928 skipping("lzma reading not fully supported on this platform"); 929 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 930 return; 931 } 932 extract_reference_file(refname); 933 934 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 935 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 936 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 937 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 938 assertEqualString("vimrc", archive_entry_pathname(ae)); 939 assertEqualIntA(a, 0, extract_one(a, ae, 0xBA8E3BAA)); 940 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 941 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 942 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 943 } 944 945 DEFINE_TEST(test_read_format_zip_lzma_stream_end_blockread) 946 { 947 const char *refname = "test_read_format_zip_lzma_stream_end.zipx"; 948 struct archive *a; 949 struct archive_entry *ae; 950 951 assert((a = archive_read_new()) != NULL); 952 if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) { 953 skipping("lzma reading not fully supported on this platform"); 954 assertEqualInt(ARCHIVE_OK, archive_read_free(a)); 955 return; 956 } 957 extract_reference_file(refname); 958 959 assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); 960 assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 37)); 961 assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); 962 assertEqualString("ZIP 6.3 (lzma)", archive_format_name(a)); 963 assertEqualString("vimrc", archive_entry_pathname(ae)); 964 assertEqualIntA(a, 0, extract_one_using_blocks(a, 13, 0xBA8E3BAA)); 965 assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); 966 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); 967 assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); 968 } 969