diff options
Diffstat (limited to 'src/lib/libcrypto/crypto/arc4random_linux.h')
| -rw-r--r-- | src/lib/libcrypto/crypto/arc4random_linux.h | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/lib/libcrypto/crypto/arc4random_linux.h b/src/lib/libcrypto/crypto/arc4random_linux.h index f02ae388d5..a713d15e06 100644 --- a/src/lib/libcrypto/crypto/arc4random_linux.h +++ b/src/lib/libcrypto/crypto/arc4random_linux.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: arc4random_linux.h,v 1.2 2014/07/18 21:40:54 matthew Exp $ */ | 1 | /* $OpenBSD: arc4random_linux.h,v 1.3 2014/07/19 00:08:43 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,15 +22,21 @@ | |||
| 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 | if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE, |
| 29 | |||
| 30 | if ((p = mmap(NULL, len, PROT_READ|PROT_WRITE, | ||
| 31 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) | 29 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) |
| 32 | return (NULL); | 30 | return (-1); |
| 33 | return (p); | 31 | |
| 32 | if ((*rsxp = mmap(NULL, sizeof(**rsxp) PROT_READ|PROT_WRITE, | ||
| 33 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) { | ||
| 34 | munmap(*rsxp, sizeof(**rsxp); | ||
| 35 | return (-1); | ||
| 36 | } | ||
| 37 | |||
| 38 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 39 | return (0); | ||
| 34 | } | 40 | } |
| 35 | 41 | ||
| 36 | static volatile sig_atomic_t _rs_forked; | 42 | static volatile sig_atomic_t _rs_forked; |
| @@ -54,10 +60,3 @@ _rs_forkdetect(void) | |||
| 54 | memset(rs, 0, sizeof(*rs)); | 60 | memset(rs, 0, sizeof(*rs)); |
| 55 | } | 61 | } |
| 56 | } | 62 | } |
| 57 | |||
| 58 | static inline void | ||
| 59 | _rs_forkdetectsetup(struct _rs *rs, size_t len) | ||
| 60 | { | ||
| 61 | _ARC4_ATFORK(_rs_forkhandler); | ||
| 62 | } | ||
| 63 | |||
