2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2015, Joyent, Inc.
33 ret
= getentropy(buf
, sizeof (buf
));
36 /* Max buffer is 256 bytes, verify if we go larger, we error */
37 ret
= getentropy(errbuf
, sizeof (errbuf
));
41 ret
= getentropy(errbuf
, 257);
45 ret
= getentropy(errbuf
, 256);
48 ret
= getentropy(errbuf
, 0);
52 ret
= getentropy(NULL
, sizeof (buf
));
54 assert(errno
== EFAULT
);
56 /* Jump through a hoop to know we'll always have a bad address */
57 addr
= mmap(NULL
, 4096, PROT_READ
, MAP_PRIVATE
| MAP_ANON
, -1, 0);
58 assert(addr
!= MAP_FAILED
);
59 ret
= munmap(addr
, 4096);
61 ret
= getentropy(addr
, sizeof (buf
));
63 assert(errno
== EFAULT
);