- fix dangerous pointer arithmetic in ParseCommandLine

Should be rewritten entirely to sanitize, though.
This commit is contained in:
Christoph Oelckers 2022-08-05 09:40:37 +02:00
parent 8d423fdc6f
commit 7e36e57639
2 changed files with 8 additions and 6 deletions

View file

@ -57,17 +57,19 @@
// \c becomes just TEXTCOLOR_ESCAPE
// $<cvar> is replaced by the contents of <cvar>
static long ParseCommandLine(const char* args, int* argc, char** argv, bool no_escapes)
static size_t ParseCommandLine(const char* args, int* argc, char** argv, bool no_escapes)
{
int count;
char* buffstart;
char* buffplace;
count = 0;
buffplace = NULL;
buffstart = NULL;
if (argv != NULL)
{
buffplace = argv[0];
buffstart = argv[0];
}
buffplace = buffstart;
for (;;)
{
@ -154,7 +156,7 @@ static long ParseCommandLine(const char* args, int* argc, char** argv, bool no_e
{
*argc = count;
}
return (long)(buffplace - (char*)0);
return (buffplace - buffstart);
}
FCommandLine::FCommandLine (const char *commandline, bool no_escapes)

View file

@ -50,9 +50,9 @@ public:
private:
const char *cmd;
bool noescapes;
int _argc;
char **_argv;
long argsize;
bool noescapes;
size_t argsize;
};