git: 9front

Download patch

ref: 6eca397226a250f3859134b28f3cb8a0fea14011
parent: 8dc06a806e0e2e6de96c6d039fa1c03216312503
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Jul 20 17:03:00 EDT 2017

kernel: fix bounds check in screenputc()

--- a/sys/src/9/bcm/screen.c
+++ b/sys/src/9/bcm/screen.c
@@ -303,7 +303,7 @@
 	static int *xp;
 	static int xbuf[256];
 
-	if (xp < xbuf || xp >= &xbuf[sizeof(xbuf)])
+	if (xp < xbuf || xp >= &xbuf[nelem(xbuf)])
 		xp = xbuf;
 
 	switch (buf[0]) {
--- a/sys/src/9/omap/screen.c
+++ b/sys/src/9/omap/screen.c
@@ -576,7 +576,7 @@
 	static int *xp;
 	static int xbuf[256];
 
-	if (xp < xbuf || xp >= &xbuf[sizeof(xbuf)])
+	if (xp < xbuf || xp >= &xbuf[nelem(xbuf)])
 		xp = xbuf;
 
 	switch (buf[0]) {
--- a/sys/src/9/pc/vga.c
+++ b/sys/src/9/pc/vga.c
@@ -53,7 +53,7 @@
 	int h, w, pos;
 	Rectangle r;
 
-	if(xp < xbuf || xp >= &xbuf[sizeof(xbuf)])
+	if(xp < xbuf || xp >= &xbuf[nelem(xbuf)])
 		xp = xbuf;
 
 	h = scr->memdefont->height;
--