]> Shamusworld >> Repos - rmac/commitdiff
Fix for bug #157 (token buffer overflow with long lines).
authorShamus Hammons <jlhamm@acm.org>
Fri, 17 Jul 2020 23:05:25 +0000 (18:05 -0500)
committerShamus Hammons <jlhamm@acm.org>
Fri, 17 Jul 2020 23:05:25 +0000 (18:05 -0500)
Also fixed a bug reported by swapd0 where a source file was longer than
65535 lines.  Now at v2.0.17.

token.c
token.h
version.h

diff --git a/token.c b/token.c
index 1e5428200bf0ce952b748445e15349f42bd09765..9299e3f7c3d7ffb9605421514ac471fded34a7d3 100644 (file)
--- 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 18ca4239666e672f2f1f4deaa5865dc0b90dabcb..95adf0157c0982d2519e78cc20e0d7a67b2f5c63 100644 (file)
--- 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;
index 452a86500e715c3619be9da314469def7505b511..14286a05e214ddbff62176791b66e4fe34ec1e3f 100644 (file)
--- 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__