From 2f2f14bf808f5f8fe521666d8e1e48abe77b93ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= Date: Sat, 2 Mar 2019 19:11:53 +0100 Subject: [PATCH] Fix symbol length checking When the while loop in `ParseSymbol` stops because of the symbol length, `copied` will have the value of `MAXSYMLEN`, which is obviously not greater than `MAXSYMLEN`. Changing the condition to `>=` fixes the issue. As a bonus, the correct union field will now be used. It shouldn't matter, but it's technically UB to use a wrong one. --- src/asm/globlex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/asm/globlex.c b/src/asm/globlex.c index 34d54f9c..e707bcd9 100644 --- a/src/asm/globlex.c +++ b/src/asm/globlex.c @@ -188,7 +188,7 @@ uint32_t ParseSymbol(char *src, uint32_t size) } } - if (copied > MAXSYMLEN) + if (copied >= MAXSYMLEN) fatalerror("Symbol too long"); dest[copied] = 0; @@ -206,7 +206,7 @@ uint32_t ParseSymbol(char *src, uint32_t size) return 0; } - strcpy(yylval.tzString, dest); + strcpy(yylval.tzSym, dest); return 1; }