Skip to content

Conversation

@luki1412
Copy link
Contributor

@luki1412 luki1412 commented Dec 31, 2025

In basebans there are 3 commands for banning: sm_banip, sm_addban, sm_ban
They have required arguments for ban duration and optional arguments for ban reason. However the functions that process the duration arguments, do not properly validate the duration and if the reason/text is provided instead of the duration, the functions just convert that string into an integer and use it as the ban duration. This usually results in a permaban with an empty reason. This commit adds a loop for checking duration string chars to be numeric before converting them to an int.

Also changing <time> to <minutes|0> for sm_banip and sm_addban to be consistent with sm_ban

Related to issue #950

Tested with sm_banip and sm_addban. Cannot test sm_ban

In basebans there are 3 commands for banning: banip,addban,ban
They have required arguments for ban duration and optional arguments for ban reason. However the functions that process the arguments do not properly validate the duration and if reason is provided instead of duration, the functions just convert that string into an integer and use it as the ban duration. This usually results in a permaban with an empty reason. This commit adds a loop for checking duration chars to be numeric before converting them to an int.
In basebans there are 3 commands for banning: banip,addban,ban
They have required arguments for ban duration and optional arguments for ban reason. However the functions that process the arguments do not properly validate the duration and if reason is provided instead of duration, the functions just convert that string into an integer and use it as the ban duration. This usually results in a permaban with an empty reason. This commit adds a loop for checking duration chars to be numeric before converting them to an int.
@luki1412 luki1412 changed the title Fix a bug where ban reason is used a ban duration Fix a bug where ban reason is used as ban duration Dec 31, 2025
@Kenzzer
Copy link
Member

Kenzzer commented Jan 1, 2026

Nice work, thanks ! There's a lot of unnecessary space formatting changes in those files, this is going to make git diffing messy. If you could undo those, then this can be merged.

@luki1412
Copy link
Contributor Author

luki1412 commented Jan 1, 2026

Added the trailing whitespace back

Copy link
Member

@Kenzzer Kenzzer left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for your hard work!

@Kenzzer Kenzzer merged commit 733e33e into alliedmodders:master Jan 1, 2026
4 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