Differences From Artifact [e9a337a52f]:
- File
src/OFZIPArchive.m
— part of check-in
[94c326ab78]
at
2022-08-27 20:33:53
on branch trunk
— OFZIPArchiveEntry: Make (un)compressedSize ull
This is for consistency with OFTarArchiveEntry and OFLHAArchiveEntry. (user: js, size: 24010) [annotate] [blame] [check-ins using]
To Artifact [6a0897ace1]:
- File src/OFZIPArchive.m — part of check-in [51589c6496] at 2022-08-27 20:39:50 on branch trunk — Rename OFFileOffset -> OFStreamOffset (user: js, size: 24030) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
138 139 140 141 142 143 144 | *size -= 8; return field; } static void seekOrThrowInvalidFormat(OFSeekableStream *stream, | | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | *size -= 8; return field; } static void seekOrThrowInvalidFormat(OFSeekableStream *stream, OFStreamOffset offset, int whence) { @try { [stream seekToOffset: offset whence: whence]; } @catch (OFSeekFailedException *e) { if (e.errNo == EINVAL) @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
197 198 199 200 201 202 203 | [self of_readZIPInfo]; [self of_readEntries]; } if (_mode == modeAppend) { _offset = _centralDirectoryOffset; seekOrThrowInvalidFormat((OFSeekableStream *)_stream, | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | [self of_readZIPInfo]; [self of_readEntries]; } if (_mode == modeAppend) { _offset = _centralDirectoryOffset; seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (OFStreamOffset)_offset, SEEK_SET); } } @catch (id e) { /* * If we are in write or append mode, we do not want -[close] * to write anything to it on error - after all, it might not * be a ZIP file which we would destroy otherwise. */ |
︙ | ︙ | |||
255 256 257 258 259 260 261 | [super dealloc]; } - (void)of_readZIPInfo { void *pool = objc_autoreleasePoolPush(); uint16_t commentLength; | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | [super dealloc]; } - (void)of_readZIPInfo { void *pool = objc_autoreleasePoolPush(); uint16_t commentLength; OFStreamOffset offset = -22; bool valid = false; do { seekOrThrowInvalidFormat((OFSeekableStream *)_stream, offset, SEEK_END); if ([_stream readLittleEndianInt32] == 0x06054B50) { |
︙ | ︙ | |||
307 308 309 310 311 312 313 | /* * FIXME: Handle number of the disk containing ZIP64 end of * central directory record. */ [_stream readLittleEndianInt32]; offset64 = [_stream readLittleEndianInt64]; | | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | /* * FIXME: Handle number of the disk containing ZIP64 end of * central directory record. */ [_stream readLittleEndianInt32]; offset64 = [_stream readLittleEndianInt64]; if (offset64 < 0 || (OFStreamOffset)offset64 != offset64) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (OFStreamOffset)offset64, SEEK_SET); if ([_stream readLittleEndianInt32] != 0x06064B50) @throw [OFInvalidFormatException exception]; size = [_stream readLittleEndianInt64]; if (size < 44) @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
334 335 336 337 338 339 340 | _centralDirectoryEntriesInDisk = [_stream readLittleEndianInt64]; _centralDirectoryEntries = [_stream readLittleEndianInt64]; _centralDirectorySize = [_stream readLittleEndianInt64]; _centralDirectoryOffset = [_stream readLittleEndianInt64]; if (_centralDirectoryOffset < 0 || | | | | | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | _centralDirectoryEntriesInDisk = [_stream readLittleEndianInt64]; _centralDirectoryEntries = [_stream readLittleEndianInt64]; _centralDirectorySize = [_stream readLittleEndianInt64]; _centralDirectoryOffset = [_stream readLittleEndianInt64]; if (_centralDirectoryOffset < 0 || (OFStreamOffset)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; } objc_autoreleasePoolPop(pool); } - (void)of_readEntries { void *pool = objc_autoreleasePoolPush(); if (_centralDirectoryOffset < 0 || (OFStreamOffset)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (OFStreamOffset)_centralDirectoryOffset, SEEK_SET); for (size_t i = 0; i < _centralDirectoryEntries; i++) { OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc] of_initWithStream: _stream] autorelease]; if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
443 444 445 446 447 448 449 | @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: ENOENT]; [self of_closeLastReturnedStream]; offset64 = entry.of_localFileHeaderOffset; | | | | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: ENOENT]; [self of_closeLastReturnedStream]; offset64 = entry.of_localFileHeaderOffset; if (offset64 < 0 || (OFStreamOffset)offset64 != offset64) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (OFStreamOffset)offset64, SEEK_SET); localFileHeader = [[[OFZIPArchiveLocalFileHeader alloc] initWithStream: _stream] autorelease]; if (![localFileHeader matchesEntry: entry]) @throw [OFInvalidFormatException exception]; if ((localFileHeader->_minVersionNeeded & 0xFF) > 45) { |
︙ | ︙ |