AllocIf would overwrite memory if the .IF nesting became too deep.

git-svn-id: svn://svn.cc65.org/cc65/trunk@1389 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2002-08-11 14:49:42 +00:00
parent b286cdf2b4
commit 4db7198ade
3 changed files with 6 additions and 6 deletions

View File

@@ -70,7 +70,7 @@ enum {
/* One .IF descriptor */ /* One .IF descriptor */
typedef struct IfDesc IfDesc; typedef struct IfDesc IfDesc;
struct IfDesc { struct IfDesc {
unsigned Flags; /* Bitmapped flags, see above */ unsigned Flags; /* Bitmapped flags, see above */
FilePos Pos; /* File position of the .IF */ FilePos Pos; /* File position of the .IF */
const char* Name; /* Name of the directive */ const char* Name; /* Name of the directive */
@@ -89,7 +89,7 @@ static IfDesc* AllocIf (const char* Directive, int NeedTerm)
/* Check for stack overflow */ /* Check for stack overflow */
if (IfCount >= MAX_IFS) { if (IfCount >= MAX_IFS) {
Error (ERR_IF_NESTING); Fatal (FAT_IF_NESTING);
} }
/* Alloc one element */ /* Alloc one element */

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -168,7 +168,6 @@ void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap)
"Symbol `%s' is already marked as export", "Symbol `%s' is already marked as export",
"Exported symbol `%s' is undefined", "Exported symbol `%s' is undefined",
"Exported values must be constant", "Exported values must be constant",
".IF nesting too deep",
"Unexpected end of file", "Unexpected end of file",
"Unexpected end of line", "Unexpected end of line",
"Unexpected `%s'", "Unexpected `%s'",
@@ -257,6 +256,7 @@ void Fatal (unsigned FatNum, ...)
"Cannot write to listing file: %s", "Cannot write to listing file: %s",
"Cannot read from listing file: %s", "Cannot read from listing file: %s",
"Too many nested constructs", "Too many nested constructs",
".IF nesting too deep",
"Too many symbols", "Too many symbols",
}; };
va_list ap; va_list ap;

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -109,7 +109,6 @@ enum Errors {
ERR_SYM_ALREADY_EXPORT, ERR_SYM_ALREADY_EXPORT,
ERR_EXPORT_UNDEFINED, ERR_EXPORT_UNDEFINED,
ERR_EXPORT_MUST_BE_CONST, ERR_EXPORT_MUST_BE_CONST,
ERR_IF_NESTING,
ERR_UNEXPECTED_EOF, ERR_UNEXPECTED_EOF,
ERR_UNEXPECTED_EOL, ERR_UNEXPECTED_EOL,
ERR_UNEXPECTED, ERR_UNEXPECTED,
@@ -148,6 +147,7 @@ enum Fatals {
FAT_CANNOT_WRITE_LISTING, FAT_CANNOT_WRITE_LISTING,
FAT_CANNOT_READ_LISTING, FAT_CANNOT_READ_LISTING,
FAT_NESTING, FAT_NESTING,
FAT_IF_NESTING,
FAT_TOO_MANY_SYMBOLS, FAT_TOO_MANY_SYMBOLS,
FAT_COUNT /* Fatal error count */ FAT_COUNT /* Fatal error count */
}; };