ObjFW  Check-in [0b7f209aef]

Overview
Comment:OFLHAArchiveEntry: Properly skip extended area
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0b7f209aefd8aac94c263953e0d8a3c73858787286fb8a06b7fa99611aec8dde
User & Date: js on 2024-02-24 13:22:56
Other Links: manifest | tags
Context
2024-02-24
13:29
OFLHAArchiveEntry: Remove pointless check check-in: 4b6a09da4c user: js tags: trunk
13:23
OFLHAArchiveEntry: Properly skip extended area check-in: 399137032a user: js tags: 1.0
13:22
OFLHAArchiveEntry: Properly skip extended area check-in: 0b7f209aef user: js tags: trunk
12:21
OFLHAArchiveEntry: Add support for header level 3 check-in: 3f79f0542a user: js tags: trunk
Changes

Modified src/OFLHAArchiveEntry.m from [146467eda7] to [e954a2772e].

20
21
22
23
24
25
26

27
28
29
30
31
32
33
#import "OFLHAArchiveEntry.h"
#import "OFLHAArchiveEntry+Private.h"
#import "OFArray.h"
#import "OFCRC16.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFNumber.h"

#import "OFStream.h"
#import "OFString.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#import "OFUnsupportedVersionException.h"







>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OFLHAArchiveEntry.h"
#import "OFLHAArchiveEntry+Private.h"
#import "OFArray.h"
#import "OFCRC16.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFNumber.h"
#import "OFSeekableStream.h"
#import "OFStream.h"
#import "OFString.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#import "OFUnsupportedVersionException.h"
366
367
368
369
370
371
372

373
374
375
376
377
378
379
380
381
382
383
384
385
386



387
388
389







390







391




392




393
394
395
396
397
398
399
		_headerLevel = header[20];
		_extensions = [[OFMutableArray alloc] init];

		switch (_headerLevel) {
		case 0:
		case 1:;
			void *pool = objc_autoreleasePoolPush();

			uint8_t fileNameLength;
			OFString *tmp;

			_modificationDate = [parseMSDOSDate(date) retain];

			fileNameLength = [stream readInt8];
			tmp = [stream readStringWithLength: fileNameLength
						  encoding: encoding];
			tmp = [tmp stringByReplacingOccurrencesOfString: @"\\"
							     withString: @"/"];
			_fileName = [tmp copy];

			_CRC16 = [stream readLittleEndianInt16];




			if (_headerLevel == 1) {
				_operatingSystemIdentifier = [stream readInt8];








				readExtensions(self, stream, encoding, false);







			}









			objc_autoreleasePoolPop(pool);
			break;
		case 2:
		case 3:
			_modificationDate = [[OFDate alloc]
			    initWithTimeIntervalSince1970: date];








>














>
>
>



>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>
>
>







367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
		_headerLevel = header[20];
		_extensions = [[OFMutableArray alloc] init];

		switch (_headerLevel) {
		case 0:
		case 1:;
			void *pool = objc_autoreleasePoolPush();
			uint8_t extendedAreaSize;
			uint8_t fileNameLength;
			OFString *tmp;

			_modificationDate = [parseMSDOSDate(date) retain];

			fileNameLength = [stream readInt8];
			tmp = [stream readStringWithLength: fileNameLength
						  encoding: encoding];
			tmp = [tmp stringByReplacingOccurrencesOfString: @"\\"
							     withString: @"/"];
			_fileName = [tmp copy];

			_CRC16 = [stream readLittleEndianInt16];

			extendedAreaSize =
			    header[0] - (21 - 2) - 1 - fileNameLength - 2;

			if (_headerLevel == 1) {
				_operatingSystemIdentifier = [stream readInt8];

				/*
				 * 1 for the operating system identifier, 2
				 * because we don't want to skip the size of
				 * the next extended header.
				 */
				extendedAreaSize -= 1 + 2;
			}

			/* Skip extended area. */
			if ([stream isKindOfClass: [OFSeekableStream class]])
				[(OFSeekableStream *)stream
				    seekToOffset: extendedAreaSize
					  whence: OFSeekCurrent];
			else {
				char buffer[256];

				while (extendedAreaSize > 0)
					extendedAreaSize -= [stream
					    readIntoBuffer: buffer
						    length: extendedAreaSize];
			}

			if (_headerLevel == 1)
				readExtensions(self, stream, encoding, false);

			objc_autoreleasePoolPop(pool);
			break;
		case 2:
		case 3:
			_modificationDate = [[OFDate alloc]
			    initWithTimeIntervalSince1970: date];