From: Shamus Hammons Date: Fri, 17 Jul 2020 23:05:25 +0000 (-0500) Subject: Fix for bug #157 (token buffer overflow with long lines). X-Git-Tag: v2.1.0~22 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=commitdiff_plain;h=e01afe2aa5b6941e79b844ee9e1bcae400e27a7c;hp=c4fcee52c8615c20a176862eeee74739f6dc3849 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. --- 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__