If a key name exceeds 4 characters, the content of scanBuf is not null-terminated, giving error messages like
syntax error: line 7 of test.xkb last scanned symbol is: FOOBARm Errors encountered in test.xkb; not compiled. (last character of the preceding 'maximum' statement in this case) X.Org Bug 66345 <http://bugs.freedesktop.org/show_bug.cgi?id=66345> Signed-off-by: Peter Hutterer <[email protected]> --- xkbscan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xkbscan.c b/xkbscan.c index a05d569..b605863 100644 --- a/xkbscan.c +++ b/xkbscan.c @@ -400,6 +400,7 @@ static int yyGetKeyName(void) { int ch, i; + int last; i = 0; while (((ch = scanchar()) != EOF) && (ch != '>')) @@ -465,12 +466,19 @@ yyGetKeyName(void) if (i < sizeof(scanBuf) - 1) scanBuf[i++] = ch; } + + if (i < sizeof(scanBuf) - i) + last = i; + else + last = sizeof(scanBuf) - 1; + + scanBuf[last] = '\0'; + if ((ch == '>') && (i < 5)) { - scanBuf[i++] = '\0'; scanStrLine = lineNum; return KEYNAME; } return ERROR_TOK; } -- 1.8.2.1 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
