1
0
Fork 0
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:
Jonas 'Sortie' Termansen 2014-01-19 18:30:07 +01:00
parent 8f8f09ac82
commit d4e7934828

View file

@ -25,6 +25,7 @@
#include <brand.h>
#include <errno.h>
#include <sortix/kernel/copy.h>
#include <sortix/kernel/kernel.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);
if ( resplen < stringlen + 1 )
return errno = ERANGE, (ssize_t) stringlen;
strcpy(resp, str);
if ( !CopyToUser(resp, str, sizeof(char) * (stringlen + 1)) )
return -1;
return 0;
}