mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
assemble: Check global line limit
Without the limit, the while loop opens to semi-infinite that will exhaustively consume the heap space. Also, the index value gets into the garbage. https://bugzilla.nasm.us/show_bug.cgi?id=3392474 Reported-by : Dongliang Mu <mudongliangabcd@gmail.com> Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
427d8e3e57
commit
f0ceb1e122
1 changed files with 6 additions and 1 deletions
|
|
@ -105,6 +105,8 @@ static const char *listname;
|
|||
static const char *errname;
|
||||
|
||||
static int globallineno; /* for forward-reference tracking */
|
||||
#define GLOBALLINENO_MAX INT32_MAX
|
||||
|
||||
/* static int pass = 0; */
|
||||
const struct ofmt *ofmt = &OF_DEFAULT;
|
||||
const struct ofmt_alias *ofmt_alias = NULL;
|
||||
|
|
@ -1342,7 +1344,10 @@ static void assemble_file(const char *fname, StrList **depend_ptr)
|
|||
location.offset = offs = get_curr_offs();
|
||||
|
||||
while ((line = preproc->getline())) {
|
||||
globallineno++;
|
||||
if (globallineno++ == GLOBALLINENO_MAX)
|
||||
nasm_error(ERR_FATAL,
|
||||
"overall line number reaches the maximum %d\n",
|
||||
GLOBALLINENO_MAX);
|
||||
|
||||
/*
|
||||
* Here we parse our directives; this is not handled by the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue