ObjFW  Check-in [3f79f0542a]

Overview
Comment:OFLHAArchiveEntry: Add support for header level 3
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3f79f0542adc6330bdc3886f3d1941bb4b2ec14cc7ba804e282808d6306d6990
User & Date: js on 2024-02-24 12:21:43
Other Links: manifest | tags
Context
2024-02-24
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
2024-02-23
23:25
OFLHAArchive: Add support for decompressing -lhx- check-in: 9350b01931 user: js tags: trunk
Changes

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

242
243
244
245
246
247
248

249

250



251
252


253
254
255
256
257

258
259
260
261
262
263
264
	return true;
}

static void
readExtensions(OFLHAArchiveEntry *entry, OFStream *stream,
    OFStringEncoding encoding, bool allowFileName)
{

	uint16_t size;





	while ((size = [stream readLittleEndianInt16]) > 0) {
		OFData *extension;



		if (size < 2)
			@throw [OFInvalidFormatException exception];

		extension = [stream readDataWithCount: size - 2];


		if (!parseExtension(entry, extension, encoding, allowFileName))
			[entry->_extensions addObject: extension];

		if (entry->_headerLevel == 1) {
			if (entry->_compressedSize < size)
				@throw [OFInvalidFormatException exception];







>
|
>

>
>
>
|
|
>
>

|


|
>







242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
	return true;
}

static void
readExtensions(OFLHAArchiveEntry *entry, OFStream *stream,
    OFStringEncoding encoding, bool allowFileName)
{
	for (;;) {
		uint32_t size;
		OFData *extension;

		if (entry->_headerLevel == 3)
			size = [stream readLittleEndianInt32];
		else
			size = [stream readLittleEndianInt16];

		if (size == 0)
			break;

		if (size < 2 || (entry->_headerLevel == 3 && size < 4))
			@throw [OFInvalidFormatException exception];

		extension = [stream readDataWithCount:
		    size - (entry->_headerLevel == 3 ? 4 : 2)];

		if (!parseExtension(entry, extension, encoding, allowFileName))
			[entry->_extensions addObject: extension];

		if (entry->_headerLevel == 1) {
			if (entry->_compressedSize < size)
				@throw [OFInvalidFormatException exception];
381
382
383
384
385
386
387

388
389
390
391
392
393




394
395
396
397
398
399
400

				readExtensions(self, stream, encoding, false);
			}

			objc_autoreleasePoolPop(pool);
			break;
		case 2:

			_modificationDate = [[OFDate alloc]
			    initWithTimeIntervalSince1970: date];

			_CRC16 = [stream readLittleEndianInt16];
			_operatingSystemIdentifier = [stream readInt8];





			readExtensions(self, stream, encoding, true);

			break;
		default:;
			OFString *version = [OFString
			    stringWithFormat: @"%u", _headerLevel];








>






>
>
>
>







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

				readExtensions(self, stream, encoding, false);
			}

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

			_CRC16 = [stream readLittleEndianInt16];
			_operatingSystemIdentifier = [stream readInt8];

			if (_headerLevel == 3)
				/* Size of header. Ignored. */
				[stream readLittleEndianInt32];

			readExtensions(self, stream, encoding, true);

			break;
		default:;
			OFString *version = [OFString
			    stringWithFormat: @"%u", _headerLevel];