From a64e1b4b41fb28235bd2ce26454a2e9f78c1f040 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 13 Mar 2013 13:22:17 +0000 Subject: Prevent buffer overflows Repeatedly pasting crazy-long single-line code into the buffer would crash tikzit before. --- tikzit/src/common/tikzlexer.lm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tikzit/src/common/tikzlexer.lm b/tikzit/src/common/tikzlexer.lm index f0b6546..a9a2e51 100644 --- a/tikzit/src/common/tikzlexer.lm +++ b/tikzit/src/common/tikzlexer.lm @@ -39,7 +39,8 @@ extern int tokenpos; %} %% %\n /* ignore end of line */; -\n.* { strcpy(linebuff, yytext+1); +\n.* { strncpy(linebuff, yytext+1, 500); + linebuff[499] = 0; // ensure null-terminated lineno++; tokenpos = 0; yyless(1); -- cgit v1.2.3