shithub: riscv

Download patch

ref: bdcef9d6928f5bdc214567937b1d219774f48b12
parent: e876447b7570808a97cbad6193b33c8af41552fe
author: cinap_lenrek <[email protected]>
date: Sat Sep 29 09:58:08 EDT 2018

5i ki qi vi: avoid buffer overflow in command read loop

--- a/sys/src/cmd/5i/cmd.c
+++ b/sys/src/cmd/5i/cmd.c
@@ -571,7 +571,7 @@
 		Bflush(bioout);
 		p = buf;
 		n = 0;
-		for(;;) {
+		while(n < sizeof(buf)) {
 			i = Bgetc(bin);
 			if(i < 0)
 				exits(0);
--- a/sys/src/cmd/ki/cmd.c
+++ b/sys/src/cmd/ki/cmd.c
@@ -568,7 +568,7 @@
 		Bflush(bioout);
 		p = buf;
 		n = 0;
-		for(;;) {
+		while(n < sizeof(buf)) {
 			i = Bgetc(bin);
 			if(i < 0)
 				exits(0);
--- a/sys/src/cmd/qi/cmd.c
+++ b/sys/src/cmd/qi/cmd.c
@@ -580,7 +580,7 @@
 		Bflush(bioout);
 		p = buf;
 		n = 0;
-		for(;;) {
+		while(n < sizeof(buf)) {
 			i = Bgetc(bin);
 			if(i < 0)
 				exits(0);
--- a/sys/src/cmd/vi/cmd.c
+++ b/sys/src/cmd/vi/cmd.c
@@ -585,7 +585,7 @@
 		Bflush(bioout);
 		p = buf;
 		n = 0;
-		for(;;) {
+		while(n < sizeof(buf)) {
 			i = Bgetc(bin);
 			if(i < 0)
 				exits(0);