From ffb28698bf5922f5d89a0d986fc6ab289fd5b6d3 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 20 Jul 2017 21:03:00 +0200 Subject: kernel: fix bounds check in screenputc() --- sys/src/9/bcm/screen.c | 2 +- sys/src/9/omap/screen.c | 2 +- sys/src/9/pc/vga.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/src') diff --git a/sys/src/9/bcm/screen.c b/sys/src/9/bcm/screen.c index a892a811d..fc0076b78 100644 --- a/sys/src/9/bcm/screen.c +++ b/sys/src/9/bcm/screen.c @@ -303,7 +303,7 @@ screenputc(char *buf) 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]) { diff --git a/sys/src/9/omap/screen.c b/sys/src/9/omap/screen.c index fe122e4eb..bc4a64b80 100644 --- a/sys/src/9/omap/screen.c +++ b/sys/src/9/omap/screen.c @@ -576,7 +576,7 @@ screenputc(char *buf) 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]) { diff --git a/sys/src/9/pc/vga.c b/sys/src/9/pc/vga.c index 6969f9e3c..fe903f0a0 100644 --- a/sys/src/9/pc/vga.c +++ b/sys/src/9/pc/vga.c @@ -53,7 +53,7 @@ vgascreenputc(VGAscr* scr, char* buf, Rectangle *flushr) 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; -- cgit v1.2.3