From 49e9edbc4bd5a89412f92cc76fae08908496057e Mon Sep 17 00:00:00 2001 From: helly Date: Mon, 3 Mar 2008 23:35:22 +0000 Subject: [PATCH] - Actually we can have better checks --- re2c/bootstrap/scanner.cc | 6 +++--- re2c/scanner.h | 8 ++++---- re2c/scanner.re | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc index c546ab92..107139ec 100644 --- a/re2c/bootstrap/scanner.cc +++ b/re2c/bootstrap/scanner.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.3.dev on Tue Mar 4 00:16:12 2008 */ +/* Generated by re2c 0.13.3.dev on Tue Mar 4 00:28:13 2008 */ /* $Id$ */ #include #include @@ -1746,9 +1746,9 @@ Scanner::~Scanner() } } -void Scanner::check_token_length(uint len) const +void Scanner::check_token_length(char *pos, uint len) const { - if (len >= BSIZE) + if (pos < bot || pos + len >= top) { fatal("Token exceeds limit"); } diff --git a/re2c/scanner.h b/re2c/scanner.h index 4aa3bb53..661b544f 100644 --- a/re2c/scanner.h +++ b/re2c/scanner.h @@ -18,7 +18,7 @@ private: std::istream& in; std::ostream& out; char *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof, *ctx; - uint tchar, tline, cline, iscfg; + uint tchar, tline, cline, iscfg, buf_size; private: char *fill(char*); @@ -39,7 +39,7 @@ public: void config(const Str&, int); void config(const Str&, const Str&); - void check_token_length(uint len) const; + void check_token_length(char *pos, uint len) const; SubStr token() const; SubStr token(uint start, uint len) const; SubStr raw_token(std::string enclosure) const; @@ -66,13 +66,13 @@ inline void Scanner::fatal(const char *msg) const inline SubStr Scanner::token() const { - check_token_length(cur - tok); + check_token_length(tok, cur - tok); return SubStr(tok, cur - tok); } inline SubStr Scanner::token(uint start, uint len) const { - check_token_length(len); + check_token_length(tok + start, len); return SubStr(tok + start, len); } diff --git a/re2c/scanner.re b/re2c/scanner.re index 5261e699..9aa3336f 100644 --- a/re2c/scanner.re +++ b/re2c/scanner.re @@ -626,9 +626,9 @@ Scanner::~Scanner() } } -void Scanner::check_token_length(uint len) const +void Scanner::check_token_length(char *pos, uint len) const { - if (len >= BSIZE) + if (pos < bot || pos + len >= top) { fatal("Token exceeds limit"); } -- 2.40.0