From 165ae5d91f798d754db9513da0e2f453f9feeb56 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Thu, 8 Nov 2012 22:56:12 +0000 Subject: Fixed item_db parser: 1. map server would crash with mismatching curly braces in unequip script field 2. the parser wouldn't accept specific combinations of curly braces in the uniquip script field. special thanks to mkbu95! git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16878 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/itemdb.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/map') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 7ea11ef7a..e0c964de3 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1171,12 +1171,22 @@ static int itemdb_readdb(void) continue; } str[21] = p; - - p = strstr(p+1,"}"); - if ( strchr(p,',') != NULL ) - { - ShowError("itemdb_readdb: Extra columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); - continue; + + if ( str[21][strlen(str[21])-2] != '}' ) { + /* lets count to ensure it's not something silly e.g. a extra space at line ending */ + int v, lcurly = 0, rcurly = 0; + + for( v = 0; v < strlen(str[21]); v++ ) { + if( str[21][v] == '{' ) + lcurly++; + else if ( str[21][v] == '}' ) + rcurly++; + } + + if( lcurly != rcurly ) { + ShowError("itemdb_readdb: Mismatching curly braces in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + continue; + } } if (!itemdb_parse_dbrow(str, path, lines, 0)) -- cgit v1.2.3-70-g09d2