Browse Source

Some equip slot checks to make sure LUA isn't abused for wrong slot numbers

Image 3 years ago
parent
commit
ac1ecda564
2 changed files with 7 additions and 0 deletions
  1. 4 0
      EQ2/source/WorldServer/Entity.cpp
  2. 3 0
      EQ2/source/WorldServer/Entity.h

+ 4 - 0
EQ2/source/WorldServer/Entity.cpp

@@ -1123,6 +1123,10 @@ void Entity::SetEquipment(Item* item, int8 slot){
 	else{
 		if ( slot >= NUM_SLOTS ) 
 			slot = item->details.slot_id;
+
+		if( slot >= NUM_SLOTS )
+			return;
+		
 		SetInfo(&equipment.equip_id[slot], item->generic_info.appearance_id);
 		SetInfo(&equipment.color[slot].red, item->generic_info.appearance_red);
 		SetInfo(&equipment.color[slot].green, item->generic_info.appearance_green);

+ 3 - 0
EQ2/source/WorldServer/Entity.h

@@ -1202,6 +1202,9 @@ public:
 	void SetEquipment(Item* item, int8 slot = 255);
 	void SetEquipment(int8 slot, int16 type, int8 red, int8 green, int8 blue, int8 h_r, int8 h_g, int8 h_b){
 		std::lock_guard<std::mutex> lk(MEquipment);
+		if(slot >= NUM_SLOTS)
+			return;
+		
 		SetInfo(&equipment.equip_id[slot], type);
 		SetInfo(&equipment.color[slot].red, red);
 		SetInfo(&equipment.color[slot].green, green);