ObjFW  Check-in [08a06ee30d]

Overview
Comment:OFZooArchive: Zero-terminate directory & file name
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 08a06ee30da2f08b717720794824ddb1f27ff0962f34a5eba911a422c1759725
User & Date: js on 2024-03-10 01:47:24
Other Links: manifest | tags
Context
2024-03-10
16:03
Add test for -[OFIRI IRIByAppendingPathComponent:] check-in: 3f3ddad4c8 user: js tags: trunk
01:47
OFZooArchive: Zero-terminate directory & file name check-in: 08a06ee30d user: js tags: trunk
2024-03-09
22:06
OFTarArchiveEntry: Add default modification date check-in: 55149a21bb user: js tags: trunk
Changes

Modified src/OFZooArchiveEntry.m from [b94a906de8] to [656f2fecb7].

344
345
346
347
348
349
350
351

352
353
354
355
356

357
358
359
360
361
362
363
344
345
346
347
348
349
350

351
352
353
354
355

356
357
358
359
360
361
362
363







-
+




-
+







		@throw [OFOutOfRangeException exception];

	commentLength = [_fileComment cStringLengthWithEncoding: encoding];
	if (commentLength > UINT16_MAX)
		@throw [OFOutOfRangeException exception];

	fileNameLength = [_fileName cStringLengthWithEncoding: encoding];
	if (fileNameLength > UINT8_MAX)
	if (fileNameLength > UINT8_MAX - 1)
		@throw [OFOutOfRangeException exception];

	directoryNameLength =
	    [_directoryName cStringLengthWithEncoding: encoding];
	if (directoryNameLength > UINT8_MAX)
	if (directoryNameLength > UINT8_MAX - 1)
		@throw [OFOutOfRangeException exception];

	[data addItems: "\xDC\xA7\xC4\xFD" count: 4];
	/* Header type */
	[data addItem: "\x02"];
	[data addItem: &_compressionMethod];

409
410
411
412
413
414
415






416
417
418
419
420
421
422
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428







+
+
+
+
+
+








	/*
	 * CRC16 is filled when writing the next header, as the CRC needs to
	 * include the next header offset.
	 */
	[data increaseCountBy: 2];

	/* Include \0 */
	if (fileNameLength > 0)
		fileNameLength++;
	if (directoryNameLength > 0)
		directoryNameLength++;

	tmp8 = (uint8_t)fileNameLength;
	[data addItem: &tmp8];
	tmp8 = (uint8_t)directoryNameLength;
	[data addItem: &tmp8];

	[data addItems: [_fileName cStringWithEncoding: encoding]
		 count: fileNameLength];