diff options
author | evan <evanbonner99@gmail.com> | 2023-03-06 21:16:06 +0000 |
---|---|---|
committer | evan <evanbonner99@gmail.com> | 2023-03-06 21:16:06 +0000 |
commit | 9da214a7a36393c0342258679690a83f6405a30a (patch) | |
tree | b17e0407de3c174db55390874a75014e6d97efa6 /src | |
parent | d442ab79ca91616ab15acb342013e489db5b67c2 (diff) |
Fix UB on parser error and buffer overrun in yylex
Diffstat (limited to 'src')
-rwxr-xr-x | src/gram.y | 11 | ||||
-rw-r--r-- | src/lex.c | 4 |
2 files changed, 9 insertions, 6 deletions
@@ -1239,12 +1239,15 @@ command: | // nothing | error { sc_error("syntax error: %s", line); - line[0]='\0'; + YYABORT; + //linelim = 0; //yyparse(); - linelim = -1; - yyclearin; - yyerrok; + + //line[0]='\0'; + //linelim = -1; + //yyclearin; + //yyerrok; }; term: var { @@ -160,9 +160,9 @@ int yylex() { for (tblp = linelim ? experres : statres; tblp->key; tblp++) { if (((tblp->key[0]^tokenst[0])&0137)==0) { int i = 1; - while (i<tokenl && ((tokenst[i]^tblp->key[i])&0137)==0) + while (tblp->key[i] && i<tokenl && ((tokenst[i]^tblp->key[i])&0137)==0) i++; - if (i >= tokenl) { + if (i >= tokenl && tblp->key[i] == '\0') { ret = tblp->val; colstate = (ret <= S_FORMAT); if (isgoto) { |