summaryrefslogtreecommitdiff
path: root/src/char/int_storage.c
diff options
context:
space:
mode:
authorDennis Friis <peavey@inspircd.org>2009-06-23 01:58:09 +0200
committerDennis Friis <peavey@inspircd.org>2009-06-25 01:13:20 +0200
commit7a2781853d87ea0b613efc709b6f84645541990b (patch)
treeffe21e00305dd680ee8e5e512a1a022b4cf9477f /src/char/int_storage.c
parent88d74cb2f179b074d5a81df60c2eb95f6873cf8e (diff)
downloadtmwa-7a2781853d87ea0b613efc709b6f84645541990b.tar.gz
tmwa-7a2781853d87ea0b613efc709b6f84645541990b.tar.bz2
tmwa-7a2781853d87ea0b613efc709b6f84645541990b.tar.xz
tmwa-7a2781853d87ea0b613efc709b6f84645541990b.zip
Crashbug fix for saving to big storages, derived from ea stable.
Diffstat (limited to 'src/char/int_storage.c')
-rw-r--r--src/char/int_storage.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index e8cbd26..112c84b 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -59,7 +59,7 @@ int storage_fromstr(char *str,struct storage *p)
if(str[next]=='\n' || str[next]=='\r')
return 0;
next++;
- for(i=0;str[next] && str[next]!='\t';i++){
+ for(i=0;str[next] && str[next]!='\t' && i < MAX_STORAGE;i++){
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
@@ -102,6 +102,8 @@ int storage_fromstr(char *str,struct storage *p)
else return 1;
}
+ if (i >= MAX_STORAGE)
+ printf("storage_fromstr: Found a storage line with more items than MAX_STORAGE (%d), remaining items have been discarded!\n", MAX_STORAGE);
return 0;
}
@@ -141,8 +143,8 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
if(str[next]=='\n' || str[next]=='\r')
return 0;
next++;
- for(i=0;str[next] && str[next]!='\t';i++){
- if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
+ for(i=0;str[next] && str[next]!='\t' && i < MAX_GUILD_STORAGE;i++){
+ if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[10], &len) == 12) {
@@ -184,6 +186,8 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
else return 1;
}
+ if (i >= MAX_GUILD_STORAGE)
+ printf("guild_storage_fromstr: Found a storage line with more items than MAX_GUILD_STORAGE (%d), remaining items have been discarded!\n", MAX_GUILD_STORAGE);
return 0;
}