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.
This commit is contained in:
parent
90d975e9c8
commit
666f58c711
3 changed files with 14 additions and 10 deletions
12
sysfile.c
12
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue