Output error messages for command line includes

The code that adds an include path to the array of paths doesn't check
the lenght of the path (which can cause overflows because of strcpy).

It doesn't check if the max number of paths has been reached, either.

This patch adds error messages for such cases, giving the user more
information than before and crashing the assembly instead of
continuing and failing when it can't find a file to include.
This commit is contained in:
AntonioND
2017-01-22 22:56:47 +00:00
parent f8531ed410
commit 0b5e074591

View File

@@ -179,6 +179,16 @@ fstk_Dump(void)
void void
fstk_AddIncludePath(char *s) fstk_AddIncludePath(char *s)
{ {
if (NextIncPath == MAXINCPATHS) {
fatalerror("Too many include directories passed from command line");
return;
}
if (strlen(s) > _MAX_PATH) {
fatalerror("Include path too long '%s'",s);
return;
}
strcpy(IncludePaths[NextIncPath++], s); strcpy(IncludePaths[NextIncPath++], s);
} }