diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-03-13 13:22:17 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-03-13 13:22:17 +0000 |
commit | a64e1b4b41fb28235bd2ce26454a2e9f78c1f040 (patch) | |
tree | 254fa2b15b75fb9ab3bddec4b4b67dd856834d56 /tikzit/src | |
parent | 59350af2697add579d3ecbd5de2d294feb4b371e (diff) |
Prevent buffer overflows
Repeatedly pasting crazy-long single-line code into the buffer would
crash tikzit before.
Diffstat (limited to 'tikzit/src')
-rw-r--r-- | tikzit/src/common/tikzlexer.lm | 3 |
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); |