From 0de0f92568aa219cbbc8577ec535103e44e98d18 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 10 Feb 2006 03:17:19 +0000 Subject: [PATCH] - Added range checking to mob skill loading of permillage and delay. - Fixed pc_gainexp not working for next level exp requirements above INT_MAX. - Fixed the display of @showexp not working right for exp values above INT_MAX. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5242 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 6 ++++++ src/map/mob.c | 12 +++++++++--- src/map/pc.c | 6 +++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index a237696e55..83de4dddb1 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,12 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS 2006/02/09 + * Added range checking to mob skill loading of permillage and delay to + prevent overflows. [Skotlex] + * Fixed pc_gainexp not working for next level exp requirements above + INT_MAX. [Skotlex] + * Fixed the display of @showexp not working right for exp values above + INT_MAX. [Skotlex] * Removed the conf sql code for now. Maybe will continue later with that project. Lowered the irc keepalive timer, and added some checks for use_irc that should have been there. Added a return line \n to the beginning of the title screen. [Valaris] diff --git a/src/map/mob.c b/src/map/mob.c index 5772db5518..590cbf323f 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4539,7 +4539,7 @@ static int mob_readskilldb(void) { FILE *fp; char line[1024]; - int i; + int i,tmp; const struct { char str[32]; @@ -4686,13 +4686,19 @@ static int mob_readskilldb(void) ms->skill_lv= j>battle_config.mob_max_skilllvl ? battle_config.mob_max_skilllvl : j; //we strip max skill level //Apply battle_config modifiers to rate (permillage) and delay [Skotlex] - ms->permillage=atoi(sp[5]); + tmp = atoi(sp[5]); if (battle_config.mob_skill_rate != 100) - ms->permillage = ms->permillage*battle_config.mob_skill_rate/100; + tmp = tmp*battle_config.mob_skill_rate/100; + if (tmp > 10000) + ms->permillage= 10000; + else + ms->permillage= tmp; ms->casttime=atoi(sp[6]); ms->delay=atoi(sp[7]); if (battle_config.mob_skill_delay != 100) ms->delay = ms->delay*battle_config.mob_skill_delay/100; + if (ms->delay < 0) //time overflow? + ms->delay = INT_MAX; ms->cancel=atoi(sp[8]); if( strcmp(sp[8],"yes")==0 ) ms->cancel=1; ms->target=atoi(sp[9]); diff --git a/src/map/pc.c b/src/map/pc.c index 2d55bb46c0..3b226c1228 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4593,7 +4593,7 @@ int pc_follow(struct map_session_data *sd,int target_id) int pc_checkbaselevelup(struct map_session_data *sd) { - int next = pc_nextbaseexp(sd); + unsigned int next = pc_nextbaseexp(sd); nullpo_retr(0, sd); @@ -4651,7 +4651,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) int pc_checkjoblevelup(struct map_session_data *sd) { - int next = pc_nextjobexp(sd); + unsigned int next = pc_nextjobexp(sd); nullpo_retr(0, sd); @@ -4763,7 +4763,7 @@ int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int jo if(sd->state.showexp){ sprintf(output, - "Experience Gained Base:%d (%.2f%%) Job:%d (%.2f%%)",base_exp,nextbp*(float)100,job_exp,nextjp*(float)100); + "Experience Gained Base:%u (%.2f%%) Job:%u (%.2f%%)",base_exp,nextbp*(float)100,job_exp,nextjp*(float)100); clif_disp_onlyself(sd,output,strlen(output)); }