-
Notifications
You must be signed in to change notification settings - Fork 118
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
bugfix(network): Deny players with invalid names from joining a LAN game room #1595
Conversation
OmniBlade
left a comment
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.
Looks okay to me.
GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Outdated
Show resolved
Hide resolved
xezon
left a comment
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.
Some more thoughts after taking another look.
| // 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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, testing is definitely needed here.
I was thinking of things like Surrogate pairs and Unicode special characters that will require a lot more validation/handling that what is proposed in this PR right now.
Should we limit names to only characters in the BMP for example? Require the string to be normalized to a specific normalization form?
|
Will this see another revision or is this final? |
|
It would be good to get this finalized. |
Sorry, I missed this comment entirely - will make another pass with limiting characters to only from the BMP. |
GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp
Outdated
Show resolved
Hide resolved
df66d16 to
3c3c5f2
Compare
xezon
left a comment
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.
Code looks mostly good.


This change introduces an extra validation of player names before they are allowed to join a network game.
Specifically, player names containing
,;or:are denied, as they will cause trouble with the parsing of the string representation of the GameInfo. This set of characters mirrors the set of disallowed characters in https://github.com/TheSuperHackers/GeneralsGameCode/blob/dd2bb780a9226186e1d1ffe0dc60fc8000134117/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp#L861C1-L869C1The player attempting to join will be presented with a "duplicate name" error, hinting that the name needs to be changed, as we can't introduce a new error type and retain retail compatibility.