diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2005-06-04 05:10:41 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2005-06-04 05:10:41 +0000 |
commit | b17d8df3c47c47915a02540d63ad29fd7f59595a (patch) | |
tree | 9c6ca6839b25ab8dab14c79e9fe3c3642ddca0e8 | |
parent | f55a888462678d374b01d4a2fed7f72e85384ae7 (diff) |
let the arc4random sysctl write out up to 256 bytes at once.
ok + input deraadt miod
-rw-r--r-- | sys/kern/kern_sysctl.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 1c992643d97..f8219b49762 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.125 2005/05/24 21:11:48 tedu Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.126 2005/06/04 05:10:40 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -398,8 +398,18 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case KERN_RND: return (sysctl_rdstruct(oldp, oldlenp, newp, &rndstats, sizeof(rndstats))); - case KERN_ARND: - return (sysctl_rdint(oldp, oldlenp, newp, arc4random())); + case KERN_ARND: { + char buf[256]; + + if (*oldlenp > sizeof(buf)) + *oldlenp = sizeof(buf); + if (oldp) { + arc4random_bytes(buf, *oldlenp); + if ((error = copyout(buf, oldp, *oldlenp))) + return (error); + } + return (0); + } case KERN_NOSUIDCOREDUMP: return (sysctl_int(oldp, oldlenp, newp, newlen, &nosuidcoredump)); case KERN_FSYNC: |