kernel: validnamedup() the name argument for segattach()
this moves the name validation out of segattach() to syssegattach() to make sure the segment name cannot be changed by the user while segattach looks at it.
This commit is contained in:
parent
d275add1a8
commit
b09cd67860
2 changed files with 10 additions and 4 deletions
|
@ -604,9 +604,6 @@ segattach(Proc *p, ulong attr, char *name, uintptr va, uintptr len)
|
|||
if(va != 0 && va >= USTKTOP)
|
||||
error(Ebadarg);
|
||||
|
||||
validaddr((uintptr)name, 1, 0);
|
||||
vmemchr(name, 0, ~0);
|
||||
|
||||
for(sno = 0; sno < NSEG; sno++)
|
||||
if(p->seg[sno] == nil && sno != ESEG)
|
||||
break;
|
||||
|
|
|
@ -775,7 +775,16 @@ syssegattach(va_list list)
|
|||
name = va_arg(list, char*);
|
||||
va = va_arg(list, uintptr);
|
||||
len = va_arg(list, ulong);
|
||||
return segattach(up, attr, name, va, len);
|
||||
validaddr((uintptr)name, 1, 0);
|
||||
name = validnamedup(name, 1);
|
||||
if(waserror()){
|
||||
free(name);
|
||||
nexterror();
|
||||
}
|
||||
va = segattach(up, attr, name, va, len);
|
||||
free(name);
|
||||
poperror();
|
||||
return va;
|
||||
}
|
||||
|
||||
uintptr
|
||||
|
|
Loading…
Reference in a new issue