[exim-cvs] OpenBSD 5.5 removed arc4random_stir

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Exim Git Commits Mailing List
Date:  
À: exim-cvs
Sujet: [exim-cvs] OpenBSD 5.5 removed arc4random_stir
Gitweb: http://git.exim.org/exim.git/commitdiff/46ca7017f606d1a3e7dfef09af46310cdad04da2
Commit:     46ca7017f606d1a3e7dfef09af46310cdad04da2
Parent:     903546d89b632736573e38f9b68c480c4d5d1593
Author:     Todd Lyons <tlyons@???>
AuthorDate: Thu Aug 14 05:30:54 2014 -0700
Committer:  Todd Lyons <tlyons@???>
CommitDate: Thu Aug 14 05:30:54 2014 -0700


    OpenBSD 5.5 removed arc4random_stir
---
 src/OS/os.h-OpenBSD |    7 +++++++
 src/src/expand.c    |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/src/OS/os.h-OpenBSD b/src/OS/os.h-OpenBSD
index 55bade6..9578047 100644
--- a/src/OS/os.h-OpenBSD
+++ b/src/OS/os.h-OpenBSD
@@ -5,6 +5,13 @@
#define HAVE_SYS_MOUNT_H
#define SIOCGIFCONF_GIVES_ADDR
#define HAVE_ARC4RANDOM
+/* In May 2014, OpenBSD 5.5 was released which cleaned up the arc4random_* API
+ which removed the arc4random_stir() function. Set NOT_HAVE_ARC4RANDOM_STIR
+ if the version released is past that point. */
+#include <sys/param.h>
+#if OpenBSD >= 201405
+#define NOT_HAVE_ARC4RANDOM_STIR
+#endif

typedef struct flock flock_t;

diff --git a/src/src/expand.c b/src/src/expand.c
index 70d7c7d..0b6513c 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -913,7 +913,9 @@ vaguely_random_number(int max)
 #ifdef HAVE_ARC4RANDOM
       /* cryptographically strong randomness, common on *BSD platforms, not
       so much elsewhere.  Alas. */
+#ifndef NOT_HAVE_ARC4RANDOM_STIR
       arc4random_stir();
+#endif
 #elif defined(HAVE_SRANDOM) || defined(HAVE_SRANDOMDEV)
 #ifdef HAVE_SRANDOMDEV
       /* uses random(4) for seeding */