]> git.lizzy.rs Git - plan9front.git/commitdiff
kernel: fix bounds check in screenputc()
authorcinap_lenrek <cinap_lenrek@felloff.net>
Thu, 20 Jul 2017 19:03:00 +0000 (21:03 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Thu, 20 Jul 2017 19:03:00 +0000 (21:03 +0200)
sys/src/9/bcm/screen.c
sys/src/9/omap/screen.c
sys/src/9/pc/vga.c

index a892a811d5d43eee021b4ebbb468e4efca3a25db..fc0076b7886a798165dc3d985f448f552aafbd6e 100644 (file)
@@ -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]) {
index fe122e4eb3633861d328708987a239979a67d5d3..bc4a64b809bc94dbb91cad4cdf1793ce66d53b5c 100644 (file)
@@ -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]) {
index 6969f9e3cb3c21162162dac4edc32a34200a2440..fe903f0a0cf398baad63f5a1d5c5bebc8b2191aa 100644 (file)
@@ -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;