diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 62459bf70b3..662ec34ceac 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -8,6 +8,7 @@ //Don't set this very much higher then 1024 unless you like inviting people in to dos your server with message spam #define MAX_MESSAGE_LEN 1024 #define MAX_PAPER_MESSAGE_LEN 3072 +#define MAX_PAPER_FIELDS 50 #define MAX_BOOK_MESSAGE_LEN 9216 #define MAX_NAME_LEN 26 diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 635d8f1bd8e..a07303bee43 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -140,10 +140,13 @@ ..() /obj/item/weapon/paper/proc/addtofield(var/id, var/text, var/links = 0) + if(id > MAX_PAPER_FIELDS) + return + var/locid = 0 var/laststart = 1 var/textindex = 1 - while(1) // I know this can cause infinite loops and fuck up the whole server, but the if(istart==0) should be safe as fuck + while(locid <= MAX_PAPER_FIELDS) var/istart = 0 if(links) istart = findtext(info_links, "", laststart) @@ -248,11 +251,11 @@ t = "[t]" -// t = replacetext(t, "#", "") // Junk converted to nothing! + t = copytext(t, 1, MAX_PAPER_MESSAGE_LEN) //Count the fields var/laststart = 1 - while(1) + while(fields < MAX_PAPER_FIELDS) var/i = findtext(t, "", laststart) if(i==0) break