main: reject --xwayland-count below 1 - #2340
Open
adamsjo95 wants to merge 1 commit into
Open
Conversation
gamescope assumes at least one Xwayland server exists: wlserver_get_xwayland_server(0) is called without a null check in main() and in approximately 10 places in steamcompmgr.cpp. --xwayland-count 0 or a negative value the creation loop never runs, the server list stays empty, and main() results in NULL. Reject the value at parse time rather than null-checking a single call site, which would only move the crash to the next unchecked use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--xwayland-count 0and negative values segfault at startup.The creation loop in
wlserver_init()isfor (int i = 0; i < g_nXWaylandCount; i++), so a count below 1 leaveswlserver.wlr.xwayland_serversempty.main.cpp:1068then does:wlserver_get_xwayland_server()correctly returns NULL for anout-of-range index, but the return value isn't checked here.
Reproduction
Backtrace:
Why validate instead of null-check
wlserver_get_xwayland_server(0)is used unchecked inmain.cppand inroughly ten places in
steamcompmgr.cpp(2573, 4413, 4436, 5582, 5992,5997, 8783, ...), plus
wlserver.cpp367 and 872. Server 0 is assumedto exist throughout, so guarding one call site would move the crash
rather than fix it. Rejecting the input at parse time matches the
existing
parse_integer()and--backenderror handling.After
Normal operation unaffected.
meson test --suite gamescopepasses 2/2.Builds clean with
--werror(689/689). Tested onfcc1341.Independent of #, different file, different
mechanism and no dependency between them.