-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
Fix invalid client index in Basebans menu #1998
base: master
Are you sure you want to change the base?
Conversation
Fix alliedmodders#1768 The `sm_admin`-triggered Menu flow for banning players is caching client indices inside the basebans.sp `PlayerInfo` struct, and can then incorrectly use them in the menu callback without checking for the related client's UserId validity. This leads to bug alliedmodders#1768 occurring when the ban target player disconnects from the server before the banning admin could complete the banmenu UI flow. Since the related menu callbacks can't rely on the cached client index, I have removed the basebans.sp `PlayerInfo.banTarget` member entirely, in favor of the `PlayerInfo.banTarget`, and instead call `GetClientOfUserId(...)` to get & validate the target client index where necessary. The `PrepareBan(...)` function has been refactored to take a ban target UserId (instead of the target client index) accordingly.
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.
Thank you, this should have been this way from the beginning ❤️
I think the best fix would be to use |
Thanks for the review. I can work the suggested changes into this PR if that seems fine. |
Yes, adding it to this one is cool. You could even look if the player left and rejoined again while the menu was open. I don't think |
When an admin initiates a ban from a BaseBans GUI menu, track players by their AuthId (SteamID) instead of userid, so that the admin is able to target players who disconnect after that menu was constructed. If the target player is still connected, use their userid to ban the same as before this commit. If the target has disconnected, write a ban using their stored AuthId value, as with "sm_addban". This commit also revertss the `(admin==0)` check from PrepareBan that was mistakenly added by bf72128, because it would prevent banning from server/RCON (client index 0).
I've added the I've also changed the ban menu player items formatting to
The
|
Only fall back to authid lookup if userid no longer resolved to client index
Unify the client validity checks with AddTargetsToMenuByAuthId checks
Use MAX_TARGET_LENGTH over defining a new custom length
Fix #1768
The
sm_admin
-triggered Menu flow for banning players is caching client indices inside the basebans.spPlayerInfo
struct, and can then incorrectly use them in the menu callback without checking for the related client's UserId validity. This leads to bug #1768 occurring when the ban target player disconnects from the server before the banning admin could complete the banmenu UI flow.Since the related menu callbacks can't rely on the cached client index, I have removed the basebans.sp
PlayerInfo.banTarget
member entirely, in favor of thePlayerInfo.banTargetUserId
, and instead callGetClientOfUserId(...)
to get & validate the target client index where necessary. ThePrepareBan(...)
function has been refactored to take a ban target UserId (instead of the target client index) accordingly.To reproduce this bug, follow these steps:
COMMAND_FILTER_NO_BOTS
in basebans/ban.sp (so that the ban player list can be populated by fakeclients)sm_admin -> "Player Commmands" -> "Ban Player"
menu