From d0725afa8363b5f7b0612e087b48013d39339039 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 18 Jan 2015 11:37:45 -0200 Subject: Fixing 38 issues Addressing out of bounds read/write, pointless null checks on already deferenced variables, dead code. Special Thanks to 4144 and Haruna! Signed-off-by: shennetsind --- src/map/atcommand.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a947b8f47..f750b307a 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6177,14 +6177,15 @@ ACMD(users) } mapit->free(iter); - // display results for each map - for( i = 0; i < MAX_MAPINDEX; ++i ) - { - if( users[i] == 0 ) - continue;// empty + if( users_all ) { + // display results for each map + for( i = 0; i < MAX_MAPINDEX; ++i ) { + if( users[i] == 0 ) + continue;// empty - safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all)); - clif->message(sd->fd, buf); + safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all)); + clif->message(sd->fd, buf); + } } // display overall count @@ -6616,7 +6617,7 @@ ACMD(mobinfo) sprintf(atcmd_output, msg_txt(1247), monster->mexp); // MVP Bonus EXP:%u clif->message(fd, atcmd_output); - strcpy(atcmd_output, msg_txt(1248)); // MVP Items: + safestrncpy(atcmd_output, msg_txt(1248), sizeof(atcmd_output)); // MVP Items: j = 0; for (i = 0; i < MAX_MVP_DROP; i++) { if (monster->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(monster->mvpitem[i].nameid)) == NULL) @@ -7086,12 +7087,12 @@ ACMD(iteminfo) clif->message(fd, atcmd_output); if (item_data->maxchance == -1) - strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only. + safestrncpy(atcmd_output, msg_txt(1281), sizeof(atcmd_output)); // - Available in the shops only. else if ( !battle_config.atcommand_mobinfo_type ) { if( item_data->maxchance ) sprintf(atcmd_output, msg_txt(1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%% else - strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item. + safestrncpy(atcmd_output, msg_txt(1283), sizeof(atcmd_output)); // - Monsters don't drop this item. } clif->message(fd, atcmd_output); @@ -7130,7 +7131,7 @@ ACMD(whodrops) clif->message(fd, atcmd_output); if (item_data->mob[0].chance == 0) { - strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs. + safestrncpy(atcmd_output, msg_txt(1286), sizeof(atcmd_output)); // - Item is not dropped by mobs. clif->message(fd, atcmd_output); } else { sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed): -- cgit v1.2.3-70-g09d2