From 345c4f919db0cfb14813e116f84169c8bddde0a0 Mon Sep 17 00:00:00 2001 From: ultramage Date: Wed, 28 May 2008 15:07:05 +0000 Subject: Added extra safeguards against invalid inputs to pc_equipitem / pc_unequipitem (bugreport:1568). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12739 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/pc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 8f0bb9b63..289fc57b7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6331,6 +6331,11 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) nullpo_retr(0, sd); + if( n < 0 || n >= MAX_INVENTORY ) { + clif_equipitemack(sd,0,0,0); + return 0; + } + id = sd->inventory_data[n]; pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots. @@ -6481,8 +6486,12 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) int i; nullpo_retr(0, sd); -// -- moonsoul (if player is berserk then cannot unequip) -// + if( n < 0 || n >= MAX_INVENTORY ) { + clif_unequipitemack(sd,0,0,0); + return 0; + } + + // if player is berserk then cannot unequip if(!(flag&2) && sd->sc.count && (sd->sc.data[SC_BLADESTOP] || sd->sc.data[SC_BERSERK])){ clif_unequipitemack(sd,n,0,0); return 0; -- cgit v1.2.3-60-g2f50