Skip to content

Guard stale FAdmin action targets - #3305

Merged
FPtje merged 2 commits into
FPtje:masterfrom
ShiroKSH:fix/fadmin-stale-actions
Jul 13, 2026
Merged

Guard stale FAdmin action targets#3305
FPtje merged 2 commits into
FPtje:masterfrom
ShiroKSH:fix/fadmin-stale-actions

Conversation

@ShiroKSH

@ShiroKSH ShiroKSH commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • validate players/entities inside delayed FAdmin action callbacks before using them
  • reject malformed TPToPos coordinates before constructing vectors
  • avoid running scoreboard warrant/wanted commands after the selected player becomes invalid
  • return early when UnRestrictWeapon is called without a weapon argument

Why

Several admin actions keep player or entity references across timers or UI prompts. If the player disconnects, the target disappears, or the command is malformed before the callback runs, the old reference could be used directly and throw a Lua error.

Checks

  • git diff --check
  • .github/scripts/check-modified-subtree.sh

@ShiroKSH
ShiroKSH marked this pull request as ready for review July 8, 2026 18:07
@FPtje

FPtje commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution! I see that you've made quite some PRs to add defensive programming. Just for my understanding, what is the context? Are these errors you've witnessed or e.g. the results of some scan?

@ShiroKSH

ShiroKSH commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! The context is a manual/static review pass, not a production incident report. I was looking specifically for low-risk runtime error paths where callbacks or UI prompts keep player/entity references across a delay, or where malformed command input reaches GLua calls before validation.

So I have not personally seen these exact errors on a live server. I split the changes into small PRs because some of them are more obviously correctness fixes than others, and I am happy to close or narrow anything that feels too defensive for DarkRP core.

For this PR specifically, the intent is just to make FAdmin action callbacks no-op when their target/source disappeared before the delayed code runs, and to reject malformed TPToPos input before constructing vectors.

@FPtje

FPtje commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Thanks for elaborating! Due to time constraints it might take a bit before reviewing the PRs. In the meantime I'll enable the workflows.

@ShiroKSH

ShiroKSH commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

No problem at all, thanks for enabling the workflows! Take your time. I will keep an eye on the checks and adjust if anything fails.

@FPtje FPtje left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

if PHYSGUN then timer.Simple(0.5, function() target:Give("weapon_physgun") target:SelectWeapon("weapon_physgun") end) end
if PHYSGUN then
timer.Simple(0.5, function()
if not IsValid(target) then return end

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finds with these timers. Easy to forget to check validity 👍

Comment thread gamemode/modules/fadmin/fadmin/restrict/sv_restrict.lua Outdated
@FPtje
FPtje merged commit 0d801bd into FPtje:master Jul 13, 2026
2 checks passed
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 this pull request may close these issues.

2 participants