diff options
Diffstat (limited to 'src/lib/libc/crypt/arc4random.h')
-rw-r--r-- | src/lib/libc/crypt/arc4random.h | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/lib/libc/crypt/arc4random.h b/src/lib/libc/crypt/arc4random.h index e0309a3184..d867687226 100644 --- a/src/lib/libc/crypt/arc4random.h +++ b/src/lib/libc/crypt/arc4random.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: arc4random.h,v 1.1 2014/07/18 02:05:55 deraadt Exp $ */ | 1 | /* $OpenBSD: arc4random.h,v 1.2 2014/07/19 00:08:41 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> |
@@ -22,25 +22,28 @@ | |||
22 | * Stub functions for portability. | 22 | * Stub functions for portability. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | static inline void * | 25 | static inline int |
26 | _rs_allocate(size_t len) | 26 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) |
27 | { | 27 | { |
28 | void *p; | 28 | struct { |
29 | struct _rs rs; | ||
30 | struct _rsx rsx; | ||
31 | } *p; | ||
29 | 32 | ||
30 | if ((p = mmap(NULL, sizeof(*rs), PROT_READ|PROT_WRITE, | 33 | if ((p = mmap(NULL, sizeof(*p), PROT_READ|PROT_WRITE, |
31 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | 34 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) |
32 | return (NULL); | 35 | return (-1); |
33 | return (p); | 36 | if (minherit(p, sizeof(*p), MAP_INHERIT_ZERO) == -1) { |
34 | } | 37 | munmap(p, sizeof(*p)); |
38 | return (-1); | ||
39 | } | ||
35 | 40 | ||
36 | static inline void | 41 | *rsp = &p->rs; |
37 | _rs_forkdetect(void) | 42 | *rsxp = &p->rsx; |
38 | { | 43 | return (0); |
39 | } | 44 | } |
40 | 45 | ||
41 | static inline void | 46 | static inline void |
42 | _rs_forkdetectsetup(struct _rs *rs, size_t len) | 47 | _rs_forkdetect(void) |
43 | { | 48 | { |
44 | if (minherit(rs, len, MAP_INHERIT_ZERO) == -1) | ||
45 | abort(); | ||
46 | } | 49 | } |