summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorKisuka <Kisuka@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-03-09 12:50:24 +0000
committerKisuka <Kisuka@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-03-09 12:50:24 +0000
commit5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0 (patch)
tree1f546bf12a99017b41ae2fd90e0ac452f97b0282 /src/map/npc.c
parentb4208257ea0906e375024f811d8e51208d539d35 (diff)
downloadhercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.gz
hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.bz2
hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.xz
hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.zip
* Merged changes from trunk [14688:14739/trunk].
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14740 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 1bf5bd312..bc2018459 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2263,6 +2263,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
char srcname[128];
int i;
const char* end;
+ size_t length;
int src_id;
int type;
@@ -2270,12 +2271,16 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
struct npc_data* dnd;
end = strchr(start,'\n');
+ length = strlen(w2);
+
// get the npc being duplicated
- if( sscanf(w2,"duplicate(%127[^)])",srcname) != 1 )
- {
+ if( w2[length-1] != ')' || length <= 11 || length-11 >= sizeof(srcname) )
+ {// does not match 'duplicate(%127s)', name is empty or too long
ShowError("npc_parse_script: bad duplicate name in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), w2);
return end;// next line, try to continue
}
+ safestrncpy(srcname, w2+10, length-10);
+
dnd = npc_name2id(srcname);
if( dnd == NULL) {
ShowError("npc_parse_script: original npc not found for duplicate in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), srcname);