Skip to content

Commit 86fd2c4

Browse files
committed
fix rare crash on unzip
1 parent 714702f commit 86fd2c4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

loader/src/utils/file.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,11 @@ class Zip::Impl final {
422422

423423
// make sure zip files like root/../../file.txt don't get extracted to
424424
// avoid zip attacks
425+
std::error_code ec;
425426
#ifdef GEODE_IS_WINDOWS
426-
if (!std::filesystem::relative((dir / filePath).wstring(), dir.wstring()).empty()) {
427+
if (!std::filesystem::relative((dir / filePath).wstring(), dir.wstring(), ec).empty()) {
427428
#else
428-
if (!std::filesystem::relative(dir / filePath, dir).empty()) {
429+
if (!std::filesystem::relative(dir / filePath, dir, ec).empty()) {
429430
#endif
430431
if (m_entries.at(filePath).isDirectory) {
431432
GEODE_UNWRAP(file::createDirectoryAll(dir / filePath));
@@ -442,6 +443,10 @@ class Zip::Impl final {
442443
"Zip entry '{}' is not contained within zip bounds",
443444
dir / filePath
444445
);
446+
447+
if (ec) {
448+
return Err(fmt::format("Unable to check relative: {}", ec.message()));
449+
}
445450
}
446451
} while (mz_zip_goto_next_entry(m_handle) == MZ_OK);
447452

0 commit comments

Comments
 (0)