From 4f68b78c3bc082e726946a8ce9ef9ff99db58a22 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Mar 2018 09:14:33 +0100 Subject: [PATCH] - removed an unchecked fixed size buffer in the KEYCONF parser. --- src/keysections.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/keysections.cpp b/src/keysections.cpp index 461aa4436..88ca7b633 100644 --- a/src/keysections.cpp +++ b/src/keysections.cpp @@ -155,7 +155,7 @@ CCMD (addmenukey) void D_LoadWadSettings () { - char cmd[4096]; + TArray command; int lump, lastlump = 0; ParsingKeyConf = true; @@ -173,16 +173,17 @@ void D_LoadWadSettings () size_t i; // Fetch a line to execute + command.Clear(); for (i = 0; conf + i < eof && conf[i] != '\n'; ++i) { - cmd[i] = conf[i]; + command.Push(conf[i]); } if (i == 0) { conf++; continue; } - cmd[i] = 0; + command.Push(0); conf += i; if (*conf == '\n') { @@ -190,8 +191,8 @@ void D_LoadWadSettings () } // Comments begin with // - char *stop = cmd + i - 1; - char *comment = cmd; + char *stop = &command[i - 1]; + char *comment = &command[0]; int inQuote = 0; if (*stop == '\r') @@ -209,7 +210,7 @@ void D_LoadWadSettings () } comment++; } - if (comment == cmd) + if (comment == &command[0]) { // Comment at line beginning continue; } @@ -218,7 +219,7 @@ void D_LoadWadSettings () *comment = 0; } - AddCommandString (cmd); + AddCommandString (&command[0]); } } ParsingKeyConf = false;