From e01afe2aa5b6941e79b844ee9e1bcae400e27a7c Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Fri, 17 Jul 2020 18:05:25 -0500 Subject: [PATCH] Fix for bug #157 (token buffer overflow with long lines). Also fixed a bug reported by swapd0 where a source file was longer than 65535 lines. Now at v2.0.17. --- token.c | 4 ++-- token.h | 4 ++-- version.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/token.c b/token.c index 1e54282..9299e3f 100644 --- a/token.c +++ b/token.c @@ -22,7 +22,7 @@ int lnsave; // 1; strcpy() text of current line -uint16_t curlineno; // Current line number (64K max currently) +uint32_t curlineno; // Current line number (64K max currently) int totlines; // Total # of lines int mjump_align = 0; // mjump alignment flag char lntag; // Line tag @@ -1082,7 +1082,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } for(; *ln!=EOS;) { // Check to see if there's enough space in the token buffer - if (tk.cp >= ((uint8_t *)(&tokbuf[TOKBUFSIZE]))) + if (tk.cp >= ((uint8_t *)(&tokbuf[TOKBUFSIZE])) - 20) { return error("token buffer overrun"); } diff --git a/token.h b/token.h index 18ca423..95adf01 100644 --- a/token.h +++ b/token.h @@ -26,7 +26,7 @@ // Tunable definitions #define LNSIZ 1024 // Maximum size of a line of text -#define TOKBUFSIZE 400 // Size of token-line buffer +#define TOKBUFSIZE 4096 // Size of token-line buffer #define QUANTUM 4096L // # bytes to eat at a time from a file #define LNBUFSIZ (QUANTUM*2) // Size of file's buffer #define KWSIZE 7 // Maximum size of keyword in kwtab.h @@ -154,7 +154,7 @@ IREPT { // Exported variables extern int lnsave; -extern uint16_t curlineno; +extern uint32_t curlineno; extern char * curfname; extern WORD cfileno; extern TOKEN * tok; diff --git a/version.h b/version.h index 452a865..14286a0 100644 --- a/version.h +++ b/version.h @@ -15,7 +15,7 @@ #define MAJOR 2 // Major version number #define MINOR 0 // Minor version number -#define PATCH 16 // Patch release number +#define PATCH 17 // Patch release number #endif // __VERSION_H__ -- 2.37.2