Kaynağa Gözat

- Added crash protection to the mob_db txt reading when the mob_db file has lines with insufficient number of columns.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8212 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 yıl önce
ebeveyn
işleme
ce0613fb1c
2 değiştirilmiş dosya ile 7 ekleme ve 2 silme
  1. 2 0
      Changelog-Trunk.txt
  2. 5 2
      src/map/mob.c

+ 2 - 0
Changelog-Trunk.txt

@@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/08/09
+	* Added crash protection to the mob_db txt reading when the mob_db file has
+	  lines with insufficient number of columns. [Skotlex]
 	* Moved the class-change code from battle_calc_weapon_attack to
 	  skill_additional_effect. Alchemist summons now also have a chance of
 	  triggering polymorphing. [Skotlex]

+ 5 - 2
src/map/mob.c

@@ -3134,8 +3134,7 @@ static int mob_readdb(void)
 				} else
 					str[i]=p;
 			}
-
-			class_ = atoi(str[0]);
+			class_ = str[0]?atoi(str[0]):0;
 			if (class_ == 0)
 				continue; //Leave blank lines alone... [Skotlex]
 
@@ -3148,6 +3147,10 @@ static int mob_readdb(void)
 				ShowWarning("Mob with ID: %d not loaded. That ID is reserved for player classes.\n");
 				continue;
 			}
+			if(i < 38+2*MAX_MOB_DROP) {
+				ShowWarning("mob_readdb: Insufficient columns for mob with ID: %d\n", class_);
+				continue;
+			}
 			if (mob_db_data[class_] == NULL)
 				mob_db_data[class_] = aCalloc(1, sizeof (struct mob_data));