From 0aa30ccde253c42310ed952ef8325fce67005347 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 11 Nov 2007 06:41:46 +0000 Subject: [PATCH] fixed amb1121 - ban commands didn't tokenize reasons properly --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401678 --- plugins/basebans.sp | 29 +++++++++++++++++----------- plugins/basebans/ban.sp | 42 +++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/plugins/basebans.sp b/plugins/basebans.sp index bbf1ec9e..370f575a 100644 --- a/plugins/basebans.sp +++ b/plugins/basebans.sp @@ -106,10 +106,23 @@ public Action:Command_BanIp(client, args) return Plugin_Handled; } + decl len, next_len; + decl String:Arguments[256]; decl String:arg[50], String:time[20]; - GetCmdArg(1, time, sizeof(time)); - GetCmdArg(2, arg, sizeof(arg)); + GetCmdArgString(Arguments, sizeof(Arguments)); + len = BreakString(Arguments, arg, sizeof(arg)); + + if ((next_len = BreakString(Arguments[len], time, sizeof(time))) != -1) + { + len += next_len; + } + else + { + len = 0; + Arguments[0] = '\0'; + } + if (StrEqual(arg, "0")) { ReplyToCommand(client, "[SM] %t", "Cannot ban that IP"); @@ -162,32 +175,26 @@ public Action:Command_BanIp(client, args) new minutes = StringToInt(time); - new String:reason[128]; - if (args >= 3) - { - GetCmdArg(3, reason, sizeof(reason)); - } - LogAction(client, hit_client, "\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")", client, minutes, arg, - reason); + Arguments[len]); ReplyToCommand(client, "[SM] %t", "Ban added"); BanIdentity(arg, minutes, BANFLAG_IP, - reason, + Arguments[len], "sm_banip", client); if (hit_client != -1) { - KickClient(hit_client, "Banned: %s", reason); + KickClient(hit_client, "Banned: %s", Arguments[len]); } return Plugin_Handled; diff --git a/plugins/basebans/ban.sp b/plugins/basebans/ban.sp index 6080fa91..5b3bb0e5 100644 --- a/plugins/basebans/ban.sp +++ b/plugins/basebans/ban.sp @@ -1,4 +1,4 @@ -PrepareBan(client, target, time, String:reason[], size) +PrepareBan(client, target, time, const String:reason[]) { decl String:authid[64], String:name[32]; GetClientAuthString(target, authid, sizeof(authid)); @@ -25,10 +25,12 @@ PrepareBan(client, target, time, String:reason[], size) if (reason[0] == '\0') { - strcopy(reason, size, "Banned"); + BanClient(target, time, BANFLAG_AUTO, "Banned", "Banned", "sm_ban", client); + } + else + { + BanClient(target, time, BANFLAG_AUTO, reason, reason, "sm_ban", client); } - - BanClient(target, time, BANFLAG_AUTO, reason, reason, "sm_ban", client); } DisplayBanTargetMenu(client) @@ -129,7 +131,7 @@ public MenuHandler_BanReasonList(Handle:menu, MenuAction:action, param1, param2) GetMenuItem(menu, param2, info, sizeof(info)); - PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info, sizeof(info)); + PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info); } } @@ -202,9 +204,13 @@ public Action:Command_Ban(client, args) ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> [reason]"); return Plugin_Handled; } + + decl len, next_len; + decl String:Arguments[256]; + GetCmdArgString(Arguments, sizeof(Arguments)); - decl String:arg[65]; - GetCmdArg(1, arg, sizeof(arg)); + decl String:arg[65]; + len = BreakString(Arguments, arg, sizeof(arg)); new target = FindTarget(client, arg, true); if (target == -1) @@ -213,19 +219,19 @@ public Action:Command_Ban(client, args) } decl String:s_time[12]; - GetCmdArg(2, s_time, sizeof(s_time)); + if ((next_len = BreakString(Arguments[len], s_time, sizeof(s_time))) != -1) + { + len += next_len; + } + else + { + len = 0; + Arguments[0] = '\0'; + } new time = StringToInt(s_time); - decl String:reason[128]; - if (args >= 3) - { - GetCmdArg(3, reason, sizeof(reason)); - } else { - reason[0] = '\0'; - } - - PrepareBan(client, target, time, reason, sizeof(reason)); + PrepareBan(client, target, time, Arguments[len]); return Plugin_Handled; -} \ No newline at end of file +}