shithub: riscv

Download patch

ref: bc5b0254d0b86c4b11637de14dab55e191388dc5
parent: 89ae389eb670fcc4d2aff786ed502f1bbae4d4fb
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Mar 28 13:23:04 EDT 2022

pc: do not access out of bounds array element

--- a/sys/src/cmd/pc.y
+++ b/sys/src/cmd/pc.y
@@ -636,7 +636,7 @@
 		yylval.sym = getsym(buf, 1);
 		return LSYMB;
 	}
-	if(c < 128 && (kw = optab[c], kw != nil)){
+	if(c >= 0 && c < 128 && (kw = optab[c], kw != nil)){
 		b = Bgetc(in);
 		for(; kw->name[0] == c; kw++)
 			if(kw->name[0] == b)