summaryrefslogtreecommitdiff
path: root/sys/dev/rnd.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2024-08-02 01:53:22 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2024-08-02 01:53:22 +0000
commit0f7451ad421bc9f8573147b7669baf5fed22d84b (patch)
treee6b2acb3422b52def4d72aa56f52563fdc8735c9 /sys/dev/rnd.c
parentc5fb7250d82c9a7f0eac87e5aa6eaa8ff9797bef (diff)
getentropy(2) is in POSIX-2024, so adjust the #include visibility,
change the "too much" error to EINVAL, add GETENTROPY_MAX to <limits.h> (via sys/syslimits.h), and update the manpage. ok deraadt@
Diffstat (limited to 'sys/dev/rnd.c')
-rw-r--r--sys/dev/rnd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index 4ad4a73a0fc..259721d90c0 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rnd.c,v 1.228 2024/06/14 10:17:05 claudio Exp $ */
+/* $OpenBSD: rnd.c,v 1.229 2024/08/02 01:53:21 guenther Exp $ */
/*
* Copyright (c) 2011,2020 Theo de Raadt.
@@ -75,6 +75,7 @@
#include <sys/msgbuf.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
+#include <sys/syslimits.h>
#include <crypto/sha2.h>
@@ -814,11 +815,11 @@ sys_getentropy(struct proc *p, void *v, register_t *retval)
syscallarg(void *) buf;
syscallarg(size_t) nbyte;
} */ *uap = v;
- char buf[256];
+ char buf[GETENTROPY_MAX];
int error;
if (SCARG(uap, nbyte) > sizeof(buf))
- return (EIO);
+ return (EINVAL);
arc4random_buf(buf, SCARG(uap, nbyte));
if ((error = copyout(buf, SCARG(uap, buf), SCARG(uap, nbyte))) != 0)
return (error);