Fix BSP reader crashing the server, again.

This commit is contained in:
Giegue
2023-05-31 16:16:37 -03:00
parent 95461427b2
commit fa39abd61c
2 changed files with 10 additions and 3 deletions

View File

@@ -421,7 +421,11 @@ skipspace:
if (script->script_p == script->end_p) if (script->script_p == script->end_p)
break; break;
if (token_p == &token[MAXTOKEN]) 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++; script->script_p++;
} }
@@ -432,7 +436,10 @@ skipspace:
if (script->script_p == script->end_p) if (script->script_p == script->end_p)
break; break;
if (token_p == &token[MAXTOKEN]) 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; *token_p = 0;

View File

@@ -90,7 +90,7 @@ void SafeRead(FILE *f, void *buffer, int count);
char *ExpandPath(char *path); // from scripts char *ExpandPath(char *path); // from scripts
// -- scriplib.h -- // -- scriplib.h --
#define MAXTOKEN 512 #define MAXTOKEN 4096
extern char token[MAXTOKEN]; extern char token[MAXTOKEN];
bool GetToken(bool crossline); bool GetToken(bool crossline);