From 83c7f854da13d3af9d414bea8eccfb82d60f5cc2 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:55:59 -0400 Subject: [PATCH] check_Physfs: Disable support for non-zip archive types --- src/main.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1f75d6c754f..d4f0863ce6b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -704,7 +704,6 @@ static void initialize_PhysicsFS(const char *argv_0) static void check_Physfs() { const PHYSFS_ArchiveInfo **i; - bool zipfound = false; PHYSFS_Version compiled; PHYSFS_Version linked; @@ -726,10 +725,37 @@ static void check_Physfs() debug(LOG_ERROR, "Please upgrade/downgrade PhysicsFS to a different version, such as 2.0.3 or 2.0.1."); } + // Disable support for non-zip archive types + std::vector archiveExtsToRemove; + for (i = PHYSFS_supportedArchiveTypes(); *i != nullptr; i++) + { + if ((*i)->extension == nullptr) + { + continue; + } + if (strcasecmp("zip", (*i)->extension) != 0) + { + archiveExtsToRemove.push_back((*i)->extension); + } + } + for (const auto& archiveExt : archiveExtsToRemove) + { + if (PHYSFS_deregisterArchiver(archiveExt.c_str()) == 0) + { + debug(LOG_WZ, "[**] Failed to unregister archive: [%s]", archiveExt.c_str()); + } + } + + // Check for "zip" archive support + bool zipfound = false; for (i = PHYSFS_supportedArchiveTypes(); *i != nullptr; i++) { + if ((*i)->extension == nullptr) + { + continue; + } debug(LOG_WZ, "[**] Supported archive(s): [%s], which is [%s].", (*i)->extension, (*i)->description); - if (!strncasecmp("zip", (*i)->extension, 3) && !zipfound) + if (strcasecmp("zip", (*i)->extension) == 0) { zipfound = true; }