Browse Source

Added extra safeguards against invalid inputs to pc_equipitem / pc_unequipitem (bugreport:1568).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12739 54d463be-8e91-2dee-dedb-b68131a5f0ec
ultramage 17 years ago
parent
commit
af570158d8
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/map/pc.c

+ 11 - 2
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);
 	nullpo_retr(0, sd);
 
 
+	if( n < 0 || n >= MAX_INVENTORY ) {
+		clif_equipitemack(sd,0,0,0);
+		return 0;
+	}
+
 	id = sd->inventory_data[n];
 	id = sd->inventory_data[n];
 	pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
 	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;
 	int i;
 	nullpo_retr(0, sd);
 	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])){
 	if(!(flag&2) && sd->sc.count && (sd->sc.data[SC_BLADESTOP] || sd->sc.data[SC_BERSERK])){
 		clif_unequipitemack(sd,n,0,0);
 		clif_unequipitemack(sd,n,0,0);
 		return 0;
 		return 0;