Overview
Comment: | OFZIPArchive: Fix uncompressed + data descriptor |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 0.90 |
Files: | files | file ages | folders |
SHA3-256: |
aff4d1cf35c3f0d6d03df649fd9b7c31 |
User & Date: | js on 2017-08-06 20:31:18 |
Other Links: | branch diff | manifest | tags |
Context
2017-08-11
| ||
15:47 | of_asprintf: Don't require set up OFLocalization check-in: 6a96844ffe user: js tags: 0.90 | |
2017-08-06
| ||
20:31 | OFZIPArchive: Fix uncompressed + data descriptor check-in: aff4d1cf35 user: js tags: 0.90 | |
2017-08-05
| ||
17:14 | OFGZIPStream: Add missing documentation check-in: 1dd4dd4630 user: js tags: 0.90 | |
Changes
Modified src/OFZIPArchive.m from [8c3891b987] to [aac05f3a80].
︙ | ︙ | |||
69 70 71 72 73 74 75 | - initWithStream: (OFStream *)stream; - (bool)matchesEntry: (OFZIPArchiveEntry *)entry; @end @interface OFZIPArchive_FileStream: OFStream { OFStream *_stream, *_decompressedStream; | | < | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | - initWithStream: (OFStream *)stream; - (bool)matchesEntry: (OFZIPArchiveEntry *)entry; @end @interface OFZIPArchive_FileStream: OFStream { OFStream *_stream, *_decompressedStream; OFZIPArchiveEntry *_entry; uint64_t _toRead; uint32_t _CRC32; bool _atEndOfStream; } - initWithStream: (OFStream *)path entry: (OFZIPArchiveEntry *)localFileHeader; @end uint32_t of_zip_archive_read_field32(const uint8_t **data, uint16_t *size) { uint32_t field = 0; |
︙ | ︙ | |||
356 357 358 359 360 361 362 | @throw [OFUnsupportedVersionException exceptionWithVersion: version]; } _lastReturnedStream = [[OFZIPArchive_FileStream alloc] initWithStream: _stream | | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | @throw [OFUnsupportedVersionException exceptionWithVersion: version]; } _lastReturnedStream = [[OFZIPArchive_FileStream alloc] initWithStream: _stream entry: entry]; objc_autoreleasePoolPop(pool); return _lastReturnedStream; } @end |
︙ | ︙ | |||
449 450 451 452 453 454 455 | return true; } @end @implementation OFZIPArchive_FileStream - initWithStream: (OFStream *)stream | | | | < < | > | | < < < | < | < < < < < | < < < < | < | < | | | | | < < | | | | < | < < < | < | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | return true; } @end @implementation OFZIPArchive_FileStream - initWithStream: (OFStream *)stream entry: (OFZIPArchiveEntry *)entry { self = [super init]; @try { _stream = [stream retain]; switch ([entry compressionMethod]) { case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE: _decompressedStream = [stream retain]; break; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE: _decompressedStream = [[OFInflateStream alloc] initWithStream: stream]; break; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE64: _decompressedStream = [[OFInflate64Stream alloc] initWithStream: stream]; break; default: @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } _entry = [entry retain]; _toRead = [entry uncompressedSize]; _CRC32 = ~0; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [self close]; [_stream release]; [_decompressedStream release]; [_entry release]; [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; if (length > UINT64_MAX) @throw [OFOutOfRangeException exception]; if ((uint64_t)length > _toRead) length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer length: length]; if (ret == 0) _atEndOfStream = true; _toRead -= ret; _CRC32 = of_crc32(_CRC32, buffer, ret); if (_toRead == 0) if (~_CRC32 != [_entry CRC32]) @throw [OFChecksumFailedException exception]; return ret; } - (void)close { [_stream release]; _stream = nil; [super close]; } @end |