#351 build fails on OpenBSD with real arc4random(3)

For_2.1
open
nobody
None
5
2015-05-25
2015-04-07
No

2.1.5-beta and git master don't build the internal arc4random on OpenBSD because it has arc4random in libc. But there is no function arc4random_addrandom. Looks like this might be an Apple addition?

Maybe this?

diff --git a/evutil_rand.c b/evutil_rand.c
index 046a14b..dd03af2 100644
--- a/evutil_rand.c
+++ b/evutil_rand.c
@@ -195,8 +195,10 @@ evutil_secure_rng_get_bytes(void *buf, size_t n)
 void
 evutil_secure_rng_add_bytes(const char *buf, size_t n)
 {
+#if defined(EVENT__HAVE_ARC4RANDOM) && !defined(__APPLE__)
    arc4random_addrandom((unsigned char*)buf,
        n>(size_t)INT_MAX ? INT_MAX : (int)n);
+#endif
 }

 void

Discussion

  • Anonymous - 2015-04-07

    Er sorry this should be more like:

    diff --git a/evutil_rand.c b/evutil_rand.c
    index 046a14b..a90eca7 100644
    --- a/evutil_rand.c
    +++ b/evutil_rand.c
    @@ -195,8 +195,10 @@ evutil_secure_rng_get_bytes(void *buf, size_t n)
     void
     evutil_secure_rng_add_bytes(const char *buf, size_t n)
     {
    +#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(__APPLE__)
        arc4random_addrandom((unsigned char*)buf,
            n>(size_t)INT_MAX ? INT_MAX : (int)n);
    +#endif
     }
    
     void
    
     
  • Richard PALO

    Richard PALO - 2015-05-25

    currently illumos has followed OpenBSD's lead and added arc4random and arc4random_buf without either arc4random_addrandom or arc4random_stir

    I wonder if adding configure tests to this effect would be more robust?

    Attached are the patches I'm currently testing...
    patch-evutil_rand.c could probably use refining.

    latest patches updated...

     
    Last edit: Richard PALO 2015-09-19

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks