Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable 2.0.22 - Android with r11 and r12 NDK - missing arc4random_addrandom #370

Closed
smarek opened this issue Jun 26, 2016 · 14 comments
Closed

Comments

@smarek
Copy link
Contributor

smarek commented Jun 26, 2016

Hi,

i had to solve the issue, where arc4random_addrandom is not checked to be available, when building https://github.com/smarek/android-unbound-dns for Android with NDK versions r11 and r12 (this function was effectivelly never implemented, but was falsely visible as available in r10 and lower)

Would you consider adding this in the 2.0.23 stable, if it will be ever released?
Original patch file can be found here: https://github.com/smarek/android-unbound-dns/blob/master/libevent-2.0.22-stable.patch

diff --git a/configure.ac b/configure.ac
index d42edd8..f66af10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -290,7 +290,7 @@ AC_HEADER_TIME

 dnl Checks for library functions.
 AC_CHECK_FUNCS([gettimeofday vasprintf fcntl clock_gettime strtok_r strsep])
-AC_CHECK_FUNCS([getnameinfo strlcpy inet_ntop inet_pton signal sigaction strtoll inet_aton pipe eventfd sendfile mmap splice arc4random arc4random_buf issetugid geteuid getegid getprotobynumber setenv unsetenv putenv sysctl])
+AC_CHECK_FUNCS([getnameinfo strlcpy inet_ntop inet_pton signal sigaction strtoll inet_aton pipe eventfd sendfile mmap splice arc4random arc4random_addrandom arc4random_buf issetugid geteuid getegid getprotobynumber setenv unsetenv putenv sysctl])
 AC_CHECK_FUNCS([umask])

 AC_CACHE_CHECK(
diff --git a/evutil_rand.c b/evutil_rand.c
index 284341c..255e940 100644
--- a/evutil_rand.c
+++ b/evutil_rand.c
@@ -171,10 +171,11 @@ evutil_secure_rng_get_bytes(void *buf, size_t n)
    ev_arc4random_buf(buf, n);
 }

+#ifdef HAVE_ARC4RANDOM_ADDRANDOM
 void
 evutil_secure_rng_add_bytes(const char *buf, size_t n)
 {
    arc4random_addrandom((unsigned char*)buf,
        n>(size_t)INT_MAX ? INT_MAX : (int)n);
 }
-
+#endif
diff --git a/include/event2/util.h b/include/event2/util.h
index dde9113..e55c8b4 100644
--- a/include/event2/util.h
+++ b/include/event2/util.h
@@ -690,6 +690,7 @@ int evutil_secure_rng_init(void);
  */
 int evutil_secure_rng_set_urandom_device_file(char *fname);

+#ifdef HAVE_ARC4RANDOM_ADDRANDOM
 /** Seed the random number generator with extra random bytes.

     You should almost never need to call this function; it should be
@@ -705,6 +706,7 @@ int evutil_secure_rng_set_urandom_device_file(char *fname);
     @param datlen the number of bytes to read from datlen
  */
 void evutil_secure_rng_add_bytes(const char *dat, size_t datlen);
+#endif

 #ifdef __cplusplus
 }
@errzey
Copy link
Contributor

errzey commented Jun 26, 2016

I will look over this tonight.

@hepengfei
Copy link

This solve problem for me. Thanks @smarek

@rvandermeulen
Copy link

This is something we have to workaround in Mozilla code too. Would be great if this could be included in 2.1.x eventually.

@azat
Copy link
Member

azat commented Jan 15, 2017

Refs: android/ndk#48

@azat
Copy link
Member

azat commented Jan 15, 2017

Can somebody post here detailed reports? For latest libevent - 26f416c
And in the mean time I will try to create env with android ndk to test it by myself.

azat pushed a commit to azat/libevent that referenced this issue Mar 5, 2017
@azat
Copy link
Member

azat commented Mar 5, 2017

@smarek I fixed this (you can take a look into attached patch), it a little bit differs from your patch:

  • cmake support
  • arc4-less systems (linux), implicit decl warning

@azat
Copy link
Member

azat commented Mar 5, 2017

@smarek can you try 2.1?

@azat
Copy link
Member

azat commented Mar 5, 2017

From:

https://github.com:azat/libevent cmake-configure-fixes

azat pushed a commit to azat/libevent that referenced this issue Mar 6, 2017
@smarek
Copy link
Contributor Author

smarek commented Mar 7, 2017

Looks cool, will ressurrect the project over the upcoming weekend, and give out test results. Thank you @azat

azat pushed a commit to azat/libevent that referenced this issue Mar 8, 2017
@azat
Copy link
Member

azat commented Mar 24, 2017

@smarek any news?

@smarek
Copy link
Contributor Author

smarek commented Mar 27, 2017

hey @azat , yup, I've tried, just pushed my prepared update to https://github.com/smarek/android-unbound-dns/tree/development

What is not working currently, there is no way to use pre-compiled openssl (1.0.2k currently) with libevent, as configure accepts only "--enable-openssl / --disable-openssl" and not something like "--with-ssl /absolute/path/to/openssl-1.0.2k/build/"

Could you advise? Thank you!

@azat
Copy link
Member

azat commented Mar 27, 2017

@smarek take a look at this

@smarek
Copy link
Contributor Author

smarek commented Mar 30, 2017

Ok, that fixed the issue, with no patch applied, libevent compiled correctly against Android sysroot
Please see smarek/android-unbound-dns@2f849e4

I consider this ticket to be done. Close if you will.

@azat
Copy link
Member

azat commented Mar 30, 2017

Great, thanks for checking it!

@azat azat closed this as completed Mar 30, 2017
achraf-mer pushed a commit to achraf-mer/libevent that referenced this issue Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants