On Fri, Nov 25, 2022 at 10:56:09AM -0500, Nicolas Mora wrote:
> Hello,
> 
> Le 2022-11-17 à 04 h 15, Benjamin Drung a écrit :
> > 
> > We did a library transition in Ubuntu to remove this symbol:
> > https://launchpad.net/bugs/1990941
> > Attached the patch we applied.
> > 
> Thanks, I've made a new package based on your patch lately,
> libevent_2.1.12-stable-7 is in NEW for now [1]. Waiting for FTP masters to
> review the new package so the transition can start.
>

Probably late for this. But this really isn't right for a library transition.
I've read the discussion on launchpad. The orig patch to keep ABI has problem
for mixing arc4random functions from the vendored sources and glibc.

But as I read the code, the arc4random_addrandom shouldn't be called. So glibc
doesn't provide such.
(Why you want to add entropy yourself?)

Looking at other implementation that still has arc4random_addrandom, for example
https://docs.oracle.com/cd/E88353_01/html/E37843/arc4random-addrandom-3c.html
It's just empty function, provided for compatibility.

So Just make evutil_secure_rng_add_bytes noop with glibc's implemtation of
arc4random. Please see following patch.

diff --git a/evutil_rand.c b/evutil_rand.c
index 8e9afda..15deab3 100644
--- a/evutil_rand.c
+++ b/evutil_rand.c
@@ -190,14 +190,14 @@ evutil_secure_rng_get_bytes(void *buf, size_t n)
        ev_arc4random_buf(buf, n);
 }
 
-#if !defined(EVENT__HAVE_ARC4RANDOM) || 
defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM)
 void
 evutil_secure_rng_add_bytes(const char *buf, size_t n)
 {
+#if defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM)
        arc4random_addrandom((unsigned char*)buf,
            n>(size_t)INT_MAX ? INT_MAX : (int)n);
-}
 #endif
+}
 
 void
 evutil_free_secure_rng_globals_(void)
diff --git a/include/event2/util.h b/include/event2/util.h
index 02aa7ba..aa7177d 100644
--- a/include/event2/util.h
+++ b/include/event2/util.h
@@ -862,7 +862,6 @@ int evutil_secure_rng_init(void);
 EVENT2_EXPORT_SYMBOL
 int evutil_secure_rng_set_urandom_device_file(char *fname);
 
-#if !defined(EVENT__HAVE_ARC4RANDOM) || 
defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM)
 /** Seed the random number generator with extra random bytes.
 
     You should almost never need to call this function; it should be
@@ -879,7 +878,6 @@ int evutil_secure_rng_set_urandom_device_file(char *fname);
  */
 EVENT2_EXPORT_SYMBOL
 void evutil_secure_rng_add_bytes(const char *dat, size_t datlen);
-#endif
 
 #ifdef __cplusplus
 }

Reply via email to