Make sysctl_kern_arnd return a random buffer instead of a random long,

as it is expected by userland (stack protector guard setup for example).

PR:		119129
Approved by:	rwatson (mentor)
MFC after:	1 month
This commit is contained in:
Antoine Brodin 2008-02-17 16:44:48 +00:00
parent 2e9878a7c5
commit 370f990d30
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176367

View File

@ -154,14 +154,18 @@ SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD,
static int
sysctl_kern_arnd(SYSCTL_HANDLER_ARGS)
{
u_long val;
char buf[256];
size_t len;
arc4rand(&val, sizeof(val), 0);
return (sysctl_handle_long(oidp, &val, 0, req));
len = req->oldlen;
if (len > sizeof(buf))
len = sizeof(buf);
arc4rand(buf, len, 0);
return (SYSCTL_OUT(req, buf, len));
}
SYSCTL_PROC(_kern, KERN_ARND, arandom, CTLFLAG_RD,
0, 0, sysctl_kern_arnd, "L", "arc4rand");
SYSCTL_PROC(_kern, KERN_ARND, arandom, CTLTYPE_OPAQUE | CTLFLAG_RD,
NULL, 0, sysctl_kern_arnd, "", "arc4rand");
static int
sysctl_hw_physmem(SYSCTL_HANDLER_ARGS)