From fa39abd61c413050c4d06944a0b7027a6ebe0a44 Mon Sep 17 00:00:00 2001 From: Giegue Date: Wed, 31 May 2023 16:16:37 -0300 Subject: [PATCH] Fix BSP reader crashing the server, again. --- src/dlls/ripent.cpp | 11 +++++++++-- src/dlls/ripent.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dlls/ripent.cpp b/src/dlls/ripent.cpp index f15f9a6..aa42e09 100644 --- a/src/dlls/ripent.cpp +++ b/src/dlls/ripent.cpp @@ -421,7 +421,11 @@ skipspace: if (script->script_p == script->end_p) break; if (token_p == &token[MAXTOKEN]) - LOG_MESSAGE(PLID, "Token too large on line %i", scriptline); + { + // if the server does not crash before this happens, then monstermod will. + // simulate a fatal error and be verbose on why it happens. + ALERT(at_logged, "FATAL ERROR (shutting down): ReadEntsFromBSP: Line %i is too long (length > %i).", scriptline, MAXTOKEN); + } } script->script_p++; } @@ -432,7 +436,10 @@ skipspace: if (script->script_p == script->end_p) break; if (token_p == &token[MAXTOKEN]) - LOG_MESSAGE(PLID, "Token too large on line %i", scriptline); + { + // ditto + ALERT(at_logged, "FATAL ERROR (shutting down): ReadEntsFromBSP: Line %i is too long (length > %i).", scriptline, MAXTOKEN); + } } *token_p = 0; diff --git a/src/dlls/ripent.h b/src/dlls/ripent.h index f3baa75..868abed 100644 --- a/src/dlls/ripent.h +++ b/src/dlls/ripent.h @@ -90,7 +90,7 @@ void SafeRead(FILE *f, void *buffer, int count); char *ExpandPath(char *path); // from scripts // -- scriplib.h -- -#define MAXTOKEN 512 +#define MAXTOKEN 4096 extern char token[MAXTOKEN]; bool GetToken(bool crossline);