From: nasm-bot f. C. S. B. <cha...@in...> - 2018-05-05 20:48:25
|
Commit-ID: f0ceb1e122dc3523123dd8dfd6113f2e68451452 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=f0ceb1e122dc3523123dd8dfd6113f2e68451452 Author: Chang S. Bae <cha...@in...> AuthorDate: Wed, 2 May 2018 08:07:53 -0700 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 5 May 2018 23:44:33 +0300 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 <mud...@gm...> Signed-off-by: Chang S. Bae <cha...@in...> Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- asm/nasm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/asm/nasm.c b/asm/nasm.c index 666c337..ecab73b 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -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 |