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

Basebans client index is invalid #1768

Open
1 of 6 tasks
dragokas opened this issue May 12, 2022 · 0 comments · May be fixed by #1998
Open
1 of 6 tasks

Basebans client index is invalid #1768

dragokas opened this issue May 12, 2022 · 0 comments · May be fixed by #1998

Comments

@dragokas
Copy link
Contributor

dragokas commented May 12, 2022

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Environment

  • Operating System version: Linux
  • Game/AppID (with version if applicable):
  • Current SourceMod version: 1.11.0.6648
  • Current SourceMod snapshot: 1.11.0.6648
  • Current Metamod: Source snapshot: 1.10.7-dev

Description

Not sure how to reproduce.

Problematic Code (or Steps to Reproduce)

Format(title, sizeof(title), "%T: %N", "Ban reason", client, playerinfo[client].banTarget);

Logs

L 05/07/2022 - 15:06:29: [SM] Exception reported: Client index 14 is invalid (arg 6)
L 05/07/2022 - 15:06:29: [SM] Blaming: sm/basebans.smx
L 05/07/2022 - 15:06:29: [SM] Call stack trace:
L 05/07/2022 - 15:06:29: [SM]   [0] Format
L 05/07/2022 - 15:06:29: [SM]   [1] Line 129, D:\builds\build-sourcemod-msvc12\windows-1.10\build\plugins\basebans/ban.sp::DisplayBanReasonMenu
L 05/07/2022 - 15:06:29: [SM]   [2] Line 268, D:\builds\build-sourcemod-msvc12\windows-1.10\build\plugins\basebans/ban.sp::MenuHandler_BanTimeList
Rainyan added a commit to Rainyan/sourcemod that referenced this issue May 11, 2023
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 banning Menu UI flow.

Since the related Menu callbacks can't rely on the client index, I have
removed the basebans.sp `PlayerInfo.banTarget` member entirely, in favor
of the `PlayerInfo.banTargetUserId`, and instead of
`GetClientOfUserId(...)` to get & validate the client index where necessary. The `PrepareBan(...)` function has been refactored to take a ban target UserId (instead of the client index) accordingly.
Rainyan added a commit to Rainyan/sourcemod that referenced this issue May 11, 2023
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 client index, I have
removed the basebans.sp `PlayerInfo.banTarget` member entirely, in favor
of the `PlayerInfo.banTargetUserId`, and instead call
`GetClientOfUserId(...)` to get & validate the client index where
necessary. The `PrepareBan(...)` function has been refactored to take a ban target
UserId (instead of the client index) accordingly.
Rainyan added a commit to Rainyan/sourcemod that referenced this issue May 11, 2023
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.
@Rainyan Rainyan linked a pull request May 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant