usermem: always trap NULL pointers
authorAlan Cox <alan@etchedpixels.co.uk>
Fri, 21 Nov 2014 15:06:11 +0000 (15:06 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Fri, 21 Nov 2014 15:06:11 +0000 (15:06 +0000)
Low vectors are hard due to the cp/mn emulation

Kernel/usermem.c

index fae355d..78257d2 100644 (file)
@@ -11,7 +11,9 @@
 /* This checks to see if a user-supplied address is legitimate */
 usize_t valaddr(const char *base, usize_t size)
 {
-       if (base < (const char *)PROGBASE || base + size < base)
+       /* FIXME: for Z80 we should make this a udata field so that cp/m
+          emulation alone can touch below 0x100 */
+       if (!base || base < (const char *)PROGBASE || base + size < base)
                size = 0;
        else if (base + size > (const char *)udata.u_top)
                size = (char *)udata.u_top - base;