Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a safeguard to map command #564

Merged
merged 3 commits into from
Nov 27, 2023
Merged

Add a safeguard to map command #564

merged 3 commits into from
Nov 27, 2023

Conversation

GeckoEidechse
Copy link
Member

Adds safeguard to the map command that prevents it from executing if the requested map is invalid or no map argument is given.

This is basically #529 again which got reverted in #561 due to pg9182/northstar-dedicated#70

The issue in pg9182/northstar-dedicated#70 is likely caused by Wine and not launcher code. Nevertheless the PR got reverted due to not being able to locate the issue in Wine in a timely manner.

As such this PR here is marked as draft until we can figure out and solve the issue in Wine in the Docker image.

Adds safeguard to the `map` command that prevents it from executing if the requested map is invalid or no map argument is given.
@GeckoEidechse
Copy link
Member Author

cc @catornot

@GeckoEidechse GeckoEidechse changed the title Add a safeguard to map command (#529) Add a safeguard to map command Oct 3, 2023
@Jan200101
Copy link
Contributor

Figured it out (shoutouts to x64dbg) @GeckoEidechse

Stack Trace and Registers

image
image

Its crashing right here

// get maps in game dir
for (fs::directory_entry file : fs::directory_iterator(fmt::format("{}/maps", R2::g_pModName)))
{
if (file.path().extension() == ".bsp")
{
MapVPKInfo& map = vMapList.emplace_back();
map.name = file.path().stem().string();
map.parent = "R2";
map.source = MapSource_t::GAMEDIR;
}
}

because in the Docker container there is no r2/maps it throws an exception which goes uncaught.
This was not caught on Windows because it was done on a full install with the maps folder intact.

Fixes are:

  • putting it in a try ... catch (fs::filesystem_error)
  • checking if the folder exists before iterating
  • use the std::error_code overload of directory_iterator

@GeckoEidechse
Copy link
Member Author

That's amazing, many thanks for taking your time to look into this <3

cc @catornot

@GeckoEidechse GeckoEidechse marked this pull request as ready for review October 15, 2023 20:12
@GeckoEidechse
Copy link
Member Author

With #575 merged and this PR updated accordingly, this should work now.

@Jan200101 Jan200101 added the needs testing Changes from the PR still need to be tested label Oct 16, 2023
@GeckoEidechse
Copy link
Member Author

Test with

ghcr.io/pg9182/northstar-dedicated-ci:1-tf2.0.11.0-ns1.19.8-ci.c14bdc62.112.6533697962-nslauncher.0d07f4b2.6526237893

created via https://github.com/pg9182/northstar-dedicated-ci/actions/runs/6533697962

Copy link
Member

@catornot catornot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still works locally
image
👍

@GeckoEidechse GeckoEidechse removed the needs testing Changes from the PR still need to be tested label Nov 27, 2023
@GeckoEidechse GeckoEidechse merged commit da7061a into main Nov 27, 2023
4 checks passed
@GeckoEidechse GeckoEidechse deleted the map_safeguard branch November 27, 2023 23:05
GeckoEidechse added a commit that referenced this pull request Nov 30, 2023
Adds safeguard to the `map` command that prevents it from executing if the requested map is invalid or no map argument is given.

Retry of #529

Co-authored-by: cat_or_not <[email protected]>
(cherry picked from commit da7061a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants