You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(kmz): add archive limits and use temp_directory
extractAllFiles() read an archive with no ceiling on entry count or
uncompressed size, so a KMZ declaring a handful of entries that expand
into gigabytes filled the disk before anything noticed. Entry names went
unchecked too. Both are now validated before a single byte is read, and
either limit can be turned off by setting it to 0.
The mkdir() return value was ignored, so a destination that could not be
created produced a warning and then a confusing failure further down.
It now throws with the path that could not be made.
temp_directory has been in the config since the first release without
anything reading it. extractAllFiles() takes an optional destination and
falls back to that key, then to the system temp directory, giving each
call a directory of its own.
extractAllFiles() also stops throwing bare KmlException for a missing or
unreadable archive and uses KmzExtractorException like the rest of the
class. That is a narrowing, KmzExtractorException extends KmlException.
`extractAllFiles()` returns the list of entry names it wrote. It extracts whatever the archive contains, so point it at a directory you control and treat uploaded archives as untrusted input.
264
+
`extractAllFiles()` returns the list of entry names it wrote. Leave the destination out and it writes to a directory of its own under `temp_directory`, or under the system temp directory when that is null:
Archives are checked before anything is read out of them. An archive is rejected when it declares more than `max_archive_entries` entries, when its entries add up to more than `max_uncompressed_size` bytes uncompressed, or when any entry name is absolute or contains `..` and would therefore write outside the destination. Set either limit to `0` to turn it off.
265
271
266
272
## Error handling
267
273
@@ -312,8 +318,14 @@ return [
312
318
'http://earth.google.com/kml/2.0',
313
319
],
314
320
315
-
// Reserved for KMZ extraction. Not used yet.
321
+
// Where extractAllFiles() writes when given no destination.
322
+
// null means the system temp directory.
316
323
'temp_directory' => null,
324
+
325
+
// Ceilings applied to a KMZ before anything is read out of it.
0 commit comments