Skip to content

Commit

Permalink
check_Physfs: Disable support for non-zip archive types
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jun 13, 2024
1 parent 5df0840 commit 83c7f85
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<std::string> 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;
}
Expand Down

0 comments on commit 83c7f85

Please sign in to comment.