home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!world!iecc!compilers-sender
- From: przemek@viewlogic.com (Przemek Skoskiewicz)
- Subject: Input buffer overflow in lex
- Reply-To: przemek@viewlogic.com (Przemek Skoskiewicz)
- Organization: Compilers Central
- Date: Mon, 4 Jan 1993 23:53:24 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <93-01-009@comp.compilers>
- Keywords: lex, question, comment
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 30
-
- I've scanned the INDEX and the back issues, but I haven't found any
- mention of this bug.
-
- I have the following lex rule to recognize strings enclosed in double
- quotes for my grammar. I'm using SunOS 4.1.3's lex/yacc package.
-
- The problem is that the generated lex code doesn't even look at the YYLMAX
- variable, which defines the size of the yytext input buffer. As long as
- an input string to my grammar is less than the maximum size of the yytext
- buffer, everything is fine. For bigger strings, lex overwrites internal
- memory and I get a core dump. I used Purify to figure out which variable
- was getting corrupted and when.
-
- \"(\\.|[^\\"])*\" {some_action_here ();}
-
- The input string is "aaaa..." with 2000 `a' in it.
-
- Before I start hacking, has anybody ran against this problem and has a
- fix? It's rather interesting that there is not a single `if' statement in
- the yacc code that would check if the input buffer index is not greater
- than YYLMAX.
-
- Viewlogic Systems, Inc. Przemek Skoskiewicz
- 293 Boston Post Road West
- Marlborough, MA 01752-4615, USA
- email: przemek@viewlogic.com
- [See the next message. -John]
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-