Browse Source

allow symbol evutil_secure_rng_add_bytes (#578)

use arc4random_random where available or export empty symbol
android-5
Vishal Biswas 8 years ago
committed by Fredrik Fornwall
parent
commit
15f034041a
  1. 2
      packages/libevent/build.sh
  2. 19
      packages/libevent/evutil_rand.c.patch
  3. 26
      packages/libevent/evutil_secure_rng_add_bytes.patch

2
packages/libevent/build.sh

@ -1,7 +1,7 @@
TERMUX_PKG_HOMEPAGE=http://libevent.org/
TERMUX_PKG_DESCRIPTION="Library that provides asynchronous event notification"
TERMUX_PKG_VERSION=2.0.22
TERMUX_PKG_BUILD_REVISION=1
TERMUX_PKG_BUILD_REVISION=2
TERMUX_PKG_SRCURL=https://github.com/libevent/libevent/releases/download/release-${TERMUX_PKG_VERSION}-stable/libevent-${TERMUX_PKG_VERSION}-stable.tar.gz
# Strip away libevent core, extra and openssl libraries until someone uses them
TERMUX_PKG_RM_AFTER_INSTALL="bin/event_rpcgen.py lib/libevent_*"

19
packages/libevent/evutil_rand.c.patch

@ -1,19 +0,0 @@
diff -u -r ../libevent-2.0.22-stable/evutil_rand.c ./evutil_rand.c
--- ../libevent-2.0.22-stable/evutil_rand.c 2013-11-01 14:18:57.000000000 -0400
+++ ./evutil_rand.c 2016-01-03 20:05:10.168762009 -0500
@@ -171,10 +171,15 @@
ev_arc4random_buf(buf, n);
}
+#ifndef __ANDROID__
+/* The arc4random_addrandom() has been removed from 64-bit Android libc,
+ see https://bugzilla.mozilla.org/show_bug.cgi?id=931354 for motivation
+ about just removing this function completely. */
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

26
packages/libevent/evutil_secure_rng_add_bytes.patch

@ -0,0 +1,26 @@
Patch taken from https://gitweb.torproject.org/orbot.git/tree/external/libevent-patch-1
For some reason arc4random_addrandom isn't present in 64-bit android archs. !
--- ./configure.ac 2015-01-05 20:00:02.000000000 +0530
+++ ../configure.ac 2016-12-06 10:15:44.617028345 +0530
@@ -290,7 +290,7 @@
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_buf arc4random_addrandom issetugid geteuid getegid getprotobynumber setenv unsetenv putenv sysctl])
AC_CHECK_FUNCS([umask])
AC_CACHE_CHECK(
--- ./evutil_rand.c 2013-11-01 23:48:57.000000000 +0530
+++ ../evutil_rand.c 2016-12-06 10:38:19.748912002 +0530
@@ -174,7 +176,9 @@
void
evutil_secure_rng_add_bytes(const char *buf, size_t n)
{
+#ifdef _EVENT_HAVE_ARC4RANDOM_ADDRANDOM
arc4random_addrandom((unsigned char*)buf,
n>(size_t)INT_MAX ? INT_MAX : (int)n);
+#endif
}
Loading…
Cancel
Save