summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@cs.ox.ac.uk>2013-03-13 13:22:17 +0000
committerAlex Merry <alex.merry@cs.ox.ac.uk>2013-03-13 13:22:17 +0000
commita64e1b4b41fb28235bd2ce26454a2e9f78c1f040 (patch)
tree254fa2b15b75fb9ab3bddec4b4b67dd856834d56
parent59350af2697add579d3ecbd5de2d294feb4b371e (diff)
Prevent buffer overflows
Repeatedly pasting crazy-long single-line code into the buffer would crash tikzit before.
-rw-r--r--tikzit/src/common/tikzlexer.lm3
1 files changed, 2 insertions, 1 deletions
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);