home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / compiler / 2082 < prev    next >
Encoding:
Text File  |  1993-01-05  |  1.7 KB  |  44 lines

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