mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix insecure user-space pointer dereferences in sys_kernelinfo.
This commit is contained in:
parent
8f8f09ac82
commit
d4e7934828
1 changed files with 3 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include <brand.h>
|
#include <brand.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <sortix/kernel/copy.h>
|
||||||
#include <sortix/kernel/kernel.h>
|
#include <sortix/kernel/kernel.h>
|
||||||
#include <sortix/kernel/syscall.h>
|
#include <sortix/kernel/syscall.h>
|
||||||
|
|
||||||
|
@ -54,7 +55,8 @@ static ssize_t sys_kernelinfo(const char* req, char* resp, size_t resplen)
|
||||||
size_t stringlen = strlen(str);
|
size_t stringlen = strlen(str);
|
||||||
if ( resplen < stringlen + 1 )
|
if ( resplen < stringlen + 1 )
|
||||||
return errno = ERANGE, (ssize_t) stringlen;
|
return errno = ERANGE, (ssize_t) stringlen;
|
||||||
strcpy(resp, str);
|
if ( !CopyToUser(resp, str, sizeof(char) * (stringlen + 1)) )
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue