diff options
author | shennetsind <ind@henn.et> | 2015-01-18 11:37:45 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2015-01-18 11:37:45 -0200 |
commit | d0725afa8363b5f7b0612e087b48013d39339039 (patch) | |
tree | 3f521b45f4b0f0d3e7dee31cacfdd78d7be867ab /src/map/trade.c | |
parent | a3c4d675ba19df385be5d1e3966c61de7186da57 (diff) | |
download | hercules-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/trade.c')
-rw-r--r-- | src/map/trade.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/map/trade.c b/src/map/trade.c index 4d6909957..46acb4e16 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -202,16 +202,16 @@ int impossible_trade_check(struct map_session_data *sd) index = sd->deal.item[i].index; if (inventory[index].amount < sd->deal.item[i].amount) { // if more than the player have -> hack - sprintf(message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has. + snprintf(message_to_gm, sizeof(message_to_gm), msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has. intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); - sprintf(message_to_gm, msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them. + snprintf(message_to_gm, sizeof(message_to_gm), msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them. intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); // if we block people if (battle_config.ban_hack_trade < 0) { chrif->char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block set_eof(sd->fd); // forced to disconnect because of the hack // message about the ban - strcpy(message_to_gm, msg_txt(540)); // This player has been definitively blocked. + safestrncpy(message_to_gm, msg_txt(540), sizeof(message_to_gm)); // This player has been definitively blocked. // if we ban people } else if (battle_config.ban_hack_trade > 0) { chrif->char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second) @@ -220,7 +220,7 @@ int impossible_trade_check(struct map_session_data *sd) sprintf(message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s). } else // message about the ban - strcpy(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled). + safestrncpy(message_to_gm, msg_txt(508), sizeof(message_to_gm)); // This player hasn't been banned (Ban option is disabled). intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); return 1; |