ref: 0b5e0745917d065b30fd87fc3abb3e061634ee87
parent: f8531ed41003759e81a42d94dc410e9f725f1532
author: AntonioND <[email protected]>
date: Sun Jan 22 17:56:47 EST 2017
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.
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -179,6 +179,16 @@
void
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);
}