diff options
author | evan <evanbonner99@gmail.com> | 2023-03-06 20:46:16 +0000 |
---|---|---|
committer | evan <evanbonner99@gmail.com> | 2023-03-06 20:46:16 +0000 |
commit | d442ab79ca91616ab15acb342013e489db5b67c2 (patch) | |
tree | 7864c2967dac3a3753e7c588f646e8e4a373892e | |
parent | b4cfc3fef326f78b8c683707f0819886ddcd82bd (diff) |
Fix buffer overrun in yylex
-rw-r--r-- | src/lex.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -157,23 +157,23 @@ int yylex() { ret = WORD; if (!linelim || isfunc) { if (isfunc) isfunc--; - for (tblp = linelim ? experres : statres; tblp->key; tblp++) - if (((tblp->key[0]^tokenst[0])&0137)==0 - && tblp->key[tokenl]==0) { - int i = 1; - while (i<tokenl && ((tokenst[i]^tblp->key[i])&0137)==0) - i++; - if (i >= tokenl) { - ret = tblp->val; - colstate = (ret <= S_FORMAT); - if (isgoto) { - isfunc = isgoto = 0; - if (ret != K_ERROR && ret != K_INVALID) - ret = WORD; + 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) + i++; + if (i >= tokenl) { + ret = tblp->val; + colstate = (ret <= S_FORMAT); + if (isgoto) { + isfunc = isgoto = 0; + if (ret != K_ERROR && ret != K_INVALID) + ret = WORD; } break; } } + } } if (ret == WORD) { |