-
Notifications
You must be signed in to change notification settings - Fork 105
bugfix(network): Deny players with invalid names from joining a LAN game room #1595
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,7 +289,28 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) | |
} | ||
#endif | ||
|
||
// We're the host, so see if he has a duplicate name | ||
// TheSuperHackers @bugfix slurmlord 18/09/2025 need to validate the name of the connecting player before | ||
// allowing them to join to prevent messing up the format of game state string. Commas, colons, semicolons etc. | ||
// should not be in a player name. It should also not consist of only space characters. | ||
if (canJoin) | ||
{ | ||
constexpr WideChar IllegalNameChars[] = L",:;|\f\n\r\t\v"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of banning \f\n\r\t\v, how about banning all characters less than 32 ? That includes all control characters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that makes sense. As these are wide chars, are there other values or sequences beyond the traditional ASCII control characters that we should consider as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs testing. I just tested Network lobby with nickname öäü and it triggered Asserts in Debug, but otherwise worked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, testing is definitely needed here. |
||
const Bool containsIllegalChars = wcscspn(msg->name, IllegalNameChars); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can simplify further to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also be |
||
const Bool isEffectivelyEmpty = wcsspn(msg->name, L" ") == wcslen(msg->name); | ||
if (containsIllegalChars || isEffectivelyEmpty) | ||
{ | ||
// Just deny with a duplicate name reason, for backwards compatibility with retail | ||
reply.LANMessageType = LANMessage::MSG_JOIN_DENY; | ||
reply.GameNotJoined.reason = LANAPIInterface::RET_DUPLICATE_NAME; | ||
reply.GameNotJoined.gameIP = m_localIP; | ||
reply.GameNotJoined.playerIP = senderIP; | ||
canJoin = false; | ||
|
||
DEBUG_LOG(("LANAPI::handleRequestJoin - join denied because of illegal characters in the player name.")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code only affects LAN lobby, correct? If so, does this need to be replicated anywhere in Online Lobby code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't seen the online lobby code use the string representation of the GameInfo, which is the root of this problem. On the other hand I haven't looked really closely at the online lobby code either.
|
||
} | ||
} | ||
|
||
// Then see if the player has a duplicate name | ||
for (player = 0; canJoin && player<MAX_SLOTS; ++player) | ||
{ | ||
LANGameSlot *slot = m_currentGame->getLANSlot(player); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the pipe character disallowed? I created a network match and was able to match 2 players with pipes (before this change). The pipe character is popular to separate clan names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was included via a suggestion, any thoughts on this @roossienb?.
I think it would be OK to allow pipe for the parsing functionality at least - as far as I know it's
,:;
that would mess up the string splitting.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roossienb asked if pipe was a problem. It is not after testing it.