Print this page
9971 Make getrandom(2) a public interface
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/port/gen/getentropy.c
+++ new/usr/src/lib/libc/port/gen/getentropy.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 - * Copyright (c) 2015, Joyent, Inc.
13 + * Copyright (c) 2018, Joyent, Inc.
14 14 */
15 15
16 16 /*
17 17 * getentropy(3C) is an OpenBSD compatible wrapper around getrandom(2).
18 18 */
19 19
20 20 #include <errno.h>
21 21 #include <sys/random.h>
22 22
23 23 int
24 24 getentropy(void *buf, size_t buflen)
25 25 {
26 - int ret;
26 + ssize_t ret;
27 27
28 28 if (buflen > 256) {
29 29 errno = EIO;
30 30 return (-1);
31 31 }
32 32
33 33 ret = getrandom(buf, buflen, 0);
34 34 if (ret == -1 || ret != buflen) {
35 35 if (errno != EFAULT)
36 36 errno = EIO;
37 37 return (-1);
38 38 }
39 39
40 40 return (0);
41 41 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX