From b1d22b02963b16c4edcce0cd5d2bc521d97348f9 Mon Sep 17 00:00:00 2001 From: skotlex Date: Sun, 1 Apr 2007 21:15:17 +0000 Subject: - Reviewed atcommand.c and charcommand.c to make sure there's no scanf where a string argument is specified without a size limit. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10111 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 28 +++++++++++----------------- src/map/charcommand.c | 8 ++++---- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 1b12d336c..15057e75e 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -879,7 +879,7 @@ AtCommandType atcommand(struct map_session_data* sd, const int level, const char int i = 0; memset(info, 0, sizeof(AtCommandInfo)); sscanf(p, "%100s", command); - command[sizeof(command)-1] = '\0'; + command[100] = '\0'; while (atcommand_info[i].type != AtCommand_Unknown) { if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) { @@ -1411,14 +1411,11 @@ int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* comm nullpo_retr(-1, sd); - if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) { + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto )."); return -1; } - memset(atcmd_player_name, '\0', sizeof atcmd_player_name); - if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) - return -1; if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk. return -1; @@ -4369,9 +4366,6 @@ int atcommand_recall(const int fd, struct map_session_data* sd, const char* comm return -1; } - memset(atcmd_player_name, '\0', sizeof atcmd_player_name); - if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1) - return -1; if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) return -1; @@ -4442,7 +4436,7 @@ int atcommand_char_block(const int fd, struct map_session_data* sd, const char* memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) { + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block )."); return -1; } @@ -4487,7 +4481,7 @@ int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* co memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) { + if (!message || !*message || sscanf(message, "%199s %99[^\n]", atcmd_output, atcmd_player_name) < 2) { clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish