summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-28 15:07:05 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-28 15:07:05 +0000
commit345c4f919db0cfb14813e116f84169c8bddde0a0 (patch)
treeea3eef1f6f7f5a196e40be0d6301ec3859ef6fa2
parent435d1eadb9986937abd37336639c4316239c2b4f (diff)
downloadhercules-345c4f919db0cfb14813e116f84169c8bddde0a0.tar.gz
hercules-345c4f919db0cfb14813e116f84169c8bddde0a0.tar.bz2
hercules-345c4f919db0cfb14813e116f84169c8bddde0a0.tar.xz
hercules-345c4f919db0cfb14813e116f84169c8bddde0a0.zip
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
-rw-r--r--src/map/pc.c13
1 files changed, 11 insertions, 2 deletions
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;