ObjFW  Check-in [9e2ddb3a59]

Overview
Comment:OFZIPArchive: Better handling of invalid archives.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9e2ddb3a59e43500171d371c7771f24c9b3e6618016c22b4a165c36e1c6a3a07
User & Date: js on 2013-12-21 01:26:21
Other Links: manifest | tags
Context
2013-12-21
01:37
OFZIP: Better error reporting. check-in: e0f9c1b105 user: js tags: trunk
01:26
OFZIPArchive: Better handling of invalid archives. check-in: 9e2ddb3a59 user: js tags: trunk
01:12
OFZIP: Keep going after non-fatal errors. check-in: 7e6942f348 user: js tags: trunk
Changes

Modified src/OFZIPArchive.m from [a531eb9595] to [a1cf6370b1].

29
30
31
32
33
34
35

36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43







+







#import "OFChecksumFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenFileFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSeekFailedException.h"
#import "OFUnsupportedVersionException.h"

#import "autorelease.h"
#import "macros.h"

#define CRC32_MAGIC 0xEDB88320

217
218
219
220
221
222
223

224
225








226
227
228
229
230
231
232
218
219
220
221
222
223
224
225


226
227
228
229
230
231
232
233
234
235
236
237
238
239
240







+
-
-
+
+
+
+
+
+
+
+







{
	void *pool = objc_autoreleasePoolPush();
	uint16_t commentLength;
	off_t offset = -22;
	bool valid = false;

	do {
		@try {
		[_file seekToOffset: offset
			     whence: SEEK_END];
			[_file seekToOffset: offset
				     whence: SEEK_END];
		} @catch (OFSeekFailedException *e) {
			if ([e errNo] == EINVAL)
				@throw [OFInvalidFormatException exception];

			@throw e;
		}

		if ([_file readLittleEndianInt32] == 0x06054B50) {
			valid = true;
			break;
		}
	} while (--offset >= -65557);

Modified utils/Makefile from [45afd96e70] to [15e3c46c74].

26
27
28
29
30
31
32
33

34
35
36
26
27
28
29
30
31
32

33
34
35
36







-
+



				${DELETE_OK}; \
			else \
				${DELETE_FAILED}; \
			fi \
		fi \
	done

CPPFLAGS += -I../src -I../src/runtime -I..
CPPFLAGS += -I../src -I../src/runtime -I../src/exceptions -I..
LIBS := -L../src -lobjfw ${LIBS}
LD = ${OBJC}
LDFLAGS += ${LDFLAGS_RPATH}