From 666f58c711eafbdccb8abfe530b935505ab6eaa6 Mon Sep 17 00:00:00 2001 From: rsc Date: Thu, 27 Sep 2007 05:13:10 +0000 Subject: believe it or not, this was working the macro expansion of "char *cp;" turned into char *(curproc[cpu()]); which declares a dynamically sized array of char* called curproc. so then &cp == &(curproc[cpu()]) was actually a stack variable as "expected". it was one past the end of the array, but the implicit alloca allocated more than was necessary. do not tell me that making cp a #define was a bad idea. there are worse problems to fix. more on that later. --- sysfile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sysfile.c') diff --git a/sysfile.c b/sysfile.c index 279847b..a23b48a 100644 --- a/sysfile.c +++ b/sysfile.c @@ -49,11 +49,11 @@ sys_read(void) { struct file *f; int n; - char *cp; + char *p; - if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &cp, n) < 0) + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) return -1; - return fileread(f, cp, n); + return fileread(f, p, n); } int @@ -61,11 +61,11 @@ sys_write(void) { struct file *f; int n; - char *cp; + char *p; - if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &cp, n) < 0) + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) return -1; - return filewrite(f, cp, n); + return filewrite(f, p, n); } int -- cgit v1.2.3