summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2015-01-18 11:37:45 -0200
committershennetsind <ind@henn.et>2015-01-18 11:37:45 -0200
commitd0725afa8363b5f7b0612e087b48013d39339039 (patch)
tree3f521b45f4b0f0d3e7dee31cacfdd78d7be867ab /src/map/atcommand.c
parenta3c4d675ba19df385be5d1e3966c61de7186da57 (diff)
downloadhercules-d0725afa8363b5f7b0612e087b48013d39339039.tar.gz
hercules-d0725afa8363b5f7b0612e087b48013d39339039.tar.bz2
hercules-d0725afa8363b5f7b0612e087b48013d39339039.tar.xz
hercules-d0725afa8363b5f7b0612e087b48013d39339039.zip
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 <ind@henn.et>
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c23
1 files changed, 12 insertions, 11 deletions
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):