ObjFW  Check-in [e2ad3ceacb]

Overview
Comment:OFZIPArchive: Correctly handle archive comments.

Archive comments allow up to 65535 bytes after the end of central
directory record, thus the magic bytes for the end of central directory
record are not always at end - 22.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e2ad3ceacb9ba95e2dc4fb2519f09ccdfbf357dcb0fa8788031853950e2428b1
User & Date: js on 2013-10-10 22:18:52
Other Links: manifest | tags
Context
2013-10-20
11:30
Add objfw-unzip. check-in: 0964e7d687 user: js tags: trunk
2013-10-10
22:18
OFZIPArchive: Correctly handle archive comments. check-in: e2ad3ceacb user: js tags: trunk
21:33
OFDeflateStream: Fix uint_fast16_t != uint16_t. check-in: 5dbf9298bd user: js tags: trunk
Changes

Modified src/OFZIPArchive.m from [0ac2251133] to [8bbe969b1a].

147
148
149
150
151
152
153


154
155
156
157

158








159
160
161
162
163
164
165
	[super dealloc];
}

- (void)OF_readZIPInfo
{
	void *pool = objc_autoreleasePoolPush();
	uint16_t commentLength;



	[_file seekToOffset: -22
		     whence: SEEK_END];


	if ([_file readLittleEndianInt32] != 0x06054B50)








		@throw [OFInvalidFormatException exception];

	_diskNumber = [_file readLittleEndianInt16],
	_centralDirectoryDisk = [_file readLittleEndianInt16];
	_centralDirectoryEntriesInDisk = [_file readLittleEndianInt16];
	_centralDirectoryEntries = [_file readLittleEndianInt16];
	_centralDirectorySize = [_file readLittleEndianInt32];







>
>




>
|
>
>
>
>
>
>
>
>







147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
	[super dealloc];
}

- (void)OF_readZIPInfo
{
	void *pool = objc_autoreleasePoolPush();
	uint16_t commentLength;
	size_t offset = 0;
	bool valid = false;

	[_file seekToOffset: -22
		     whence: SEEK_END];

	while (offset++ < 65536) {
		if ([_file readLittleEndianInt32] == 0x06054B50) {
			valid = true;
			break;
		} else
			[_file seekToOffset: -5
				     whence: SEEK_CUR];
	}

	if (!valid)
		@throw [OFInvalidFormatException exception];

	_diskNumber = [_file readLittleEndianInt16],
	_centralDirectoryDisk = [_file readLittleEndianInt16];
	_centralDirectoryEntriesInDisk = [_file readLittleEndianInt16];
	_centralDirectoryEntries = [_file readLittleEndianInt16];
	_centralDirectorySize = [_file readLittleEndianInt32];