From cfaacd5aff51c88ae76519d019aa6427ba1c5bc0 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Tue, 4 Jun 2013 20:18:15 -0400 Subject: [PATCH 1/1] Limit maximum length of vote commands to 160 by default --- commands.cfg | 1 + qcsrc/server/autocvars.qh | 1 + qcsrc/server/command/vote.qc | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/commands.cfg b/commands.cfg index b5846f0d95..20f8b6bdab 100644 --- a/commands.cfg +++ b/commands.cfg @@ -295,6 +295,7 @@ set sv_vote_call 1 "Allow users to call a vote for the commands in sv_vote_comma set sv_vote_change 1 "Allow voters to change their mind after already voting" set sv_vote_commands "restart fraglimit chmap gotomap nextmap endmatch reducematchtime extendmatchtime allready kick cointoss movetoauto shuffleteams" "these commands can be voted" set sv_vote_only_commands "" +set sv_vote_limit 160 "Maximum allowed length of a vote command" set sv_vote_master_commands "movetored movetoblue movetoyellow movetopink" "Extra commands which vote masters can execute by themselves, along with the normal sv_vote_commands." // maybe add kickban here (but then sv_vote_master 0) set sv_vote_master 1 "Allows the use of the vote master system" set sv_vote_master_callable 1 "When set, users can use \"vmaster\" to call a vote to become master of voting commands" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index e6a242a704..dead5a9d4b 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1165,6 +1165,7 @@ float autocvar_sv_timeout_resumetime; float autocvar_sv_vote_call; float autocvar_sv_vote_change; string autocvar_sv_vote_commands; +float autocvar_sv_vote_limit; float autocvar_sv_vote_majority_factor; float autocvar_sv_vote_majority_factor_of_voted; float autocvar_sv_vote_master; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 1fa1be119a..c7010dfb75 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -668,6 +668,18 @@ float VoteCommand_parse(entity caller, string vote_command, string vote_list, fl first_command = argv(startpos); + /*dprint(sprintf("VoteCommand_parse(): Command: '%s', Length: %f.\n", + substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos)), + strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) + ));*/ + + if( + (autocvar_sv_vote_limit > 0) + && + (strlen(substring(vote_command, argv_start_index(startpos), strlen(vote_command) - argv_start_index(startpos))) > autocvar_sv_vote_limit) + ) + return FALSE; + if not(VoteCommand_checkinlist(first_command, vote_list)) return FALSE; -- 2.39.2