summaryrefslogtreecommitdiff
path: root/src/char/int_storage.c
diff options
context:
space:
mode:
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;
}