summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-08-21 17:17:27 +0200
committerHaru <haru@dotalux.com>2016-08-21 17:17:27 +0200
commitfcaf88e924900f589932bfb5e2aaa4a635a756ea (patch)
tree091ebf863202dcd61eff817da4d20396373ce2f2 /src/char/char.c
parentd58ab3d97beb5c495bc7a82c4fa71f444ba67b72 (diff)
downloadhercules-fcaf88e924900f589932bfb5e2aaa4a635a756ea.tar.gz
hercules-fcaf88e924900f589932bfb5e2aaa4a635a756ea.tar.bz2
hercules-fcaf88e924900f589932bfb5e2aaa4a635a756ea.tar.xz
hercules-fcaf88e924900f589932bfb5e2aaa4a635a756ea.zip
Corrected some issues reported by coverity
- Incorrect sizeof expression in char_config_set_ip() - Invalid comparison (when MAX_ZENY == MAX_INT) in char_config_read_player_new() Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 712d7efb2..3e78d768f 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -5919,6 +5919,7 @@ bool char_config_read_player_new(const char *filename, const struct config_t *co
#else
const char *start_point_setting = "start_point_pre";
#endif
+ int64 i64 = 0;
nullpo_retr(false, filename);
nullpo_retr(false, config);
@@ -5930,10 +5931,12 @@ bool char_config_read_player_new(const char *filename, const struct config_t *co
return false;
}
- if (libconfig->setting_lookup_int(setting, "zeny", &start_zeny) == CONFIG_TRUE) {
- if (start_zeny > MAX_ZENY) {
+ if (libconfig->setting_lookup_int64(setting, "zeny", &i64) == CONFIG_TRUE) {
+ if (i64 > MAX_ZENY) {
ShowWarning("char_config_read: player/new/zeny is too big! Capping to MAX_ZENY.\n");
start_zeny = MAX_ZENY;
+ } else {
+ start_zeny = (int)i64;
}
}
@@ -6016,8 +6019,8 @@ bool char_config_set_ip(const char *type, const char *value, uint32 *out_ip, cha
return false;
*out_ip = ip;
- ShowStatus("%s IP address : %s -> %s\n", type, out_ip_str[0] ? out_ip_str : "0.0.0.0", sockt->ip2str(ip, NULL));
- safestrncpy(out_ip_str, value, sizeof(out_ip_str));
+ ShowStatus("%s IP address : %s -> %s\n", type, out_ip_str[0] != '\0' ? out_ip_str : "0.0.0.0", sockt->ip2str(ip, NULL));
+ safestrncpy(out_ip_str, value, sizeof *out_ip_str);
return true;
}