ObjFW  Check-in [927d1693c6]

Overview
Comment:OFLHAArchive: Ignore trailing garbage
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 1.0
Files: files | file ages | folders
SHA3-256: 927d1693c6dd67218e60aa3e4035f3a66c079748916723f0f964ba034834193b
User & Date: js on 2024-02-24 17:25:03
Other Links: branch diff | manifest | tags
Context
2024-02-24
19:43
runtime: Fix objc_getClassList not unlocking mutex check-in: 7a33596a17 user: js tags: 1.0
17:25
OFLHAArchive: Ignore trailing garbage check-in: 927d1693c6 user: js tags: 1.0
17:24
OFLHAArchive: Ignore trailing garbage check-in: 35257251ec user: js tags: trunk
15:05
OFLHAArchiveEntry: Add extra sanity checks check-in: 581e18268c user: js tags: 1.0
Changes

Modified src/OFLHAArchive.m from [e41cd8005a] to [70eb128b91].

212
213
214
215
216
217
218










219
220
221
222
223
224
225
			@throw [OFTruncatedDataException exception];
		}

		headerLen += [_stream readIntoBuffer: header + headerLen
					      length: 21 - headerLen];
	}











	_currentEntry = [[OFLHAArchiveEntry alloc]
	    of_initWithHeader: header
		       stream: _stream
		     encoding: _encoding];

	return _currentEntry;
}







>
>
>
>
>
>
>
>
>
>







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
			@throw [OFTruncatedDataException exception];
		}

		headerLen += [_stream readIntoBuffer: header + headerLen
					      length: 21 - headerLen];
	}

	/*
	 * Some archives have trailing garbage after the single byte 0
	 * termination. However, a level 2 header uses 2 bytes for the size, so
	 * could just have a header size that is a multiple of 256. Therefore,
	 * consider it only the end of the archive if what follows would not be
	 * a level 2 header.
	 */
	if (header[0] == 0 && header[20] != 2)
		return nil;

	_currentEntry = [[OFLHAArchiveEntry alloc]
	    of_initWithHeader: header
		       stream: _stream
		     encoding: _encoding];

	return _currentEntry;
}