ipc/chromium/src/third_party/libevent/mac-arc4random-buf.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/third_party/libevent/mac-arc4random-buf.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +--- a/evutil_rand.c	2012-08-02 10:36:53.000000000 -0500
     1.5 ++++ b/evutil_rand.c	2013-02-20 13:01:45.000000000 -0600
     1.6 +@@ -58,27 +58,16 @@ evutil_secure_rng_global_setup_locks_(co
     1.7 + static void
     1.8 + ev_arc4random_buf(void *buf, size_t n)
     1.9 + {
    1.10 + #if defined(_EVENT_HAVE_ARC4RANDOM_BUF) && !defined(__APPLE__)
    1.11 + 	return arc4random_buf(buf, n);
    1.12 + #else
    1.13 + 	unsigned char *b = buf;
    1.14 + 
    1.15 +-#if defined(_EVENT_HAVE_ARC4RANDOM_BUF)
    1.16 +-	/* OSX 10.7 introducd arc4random_buf, so if you build your program
    1.17 +-	 * there, you'll get surprised when older versions of OSX fail to run.
    1.18 +-	 * To solve this, we can check whether the function pointer is set,
    1.19 +-	 * and fall back otherwise.  (OSX does this using some linker
    1.20 +-	 * trickery.)
    1.21 +-	 */
    1.22 +-	if (arc4random_buf != NULL) {
    1.23 +-		return arc4random_buf(buf, n);
    1.24 +-	}
    1.25 +-#endif
    1.26 + 	/* Make sure that we start out with b at a 4-byte alignment; plenty
    1.27 + 	 * of CPUs care about this for 32-bit access. */
    1.28 + 	if (n >= 4 && ((ev_uintptr_t)b) & 3) {
    1.29 + 		ev_uint32_t u = arc4random();
    1.30 + 		int n_bytes = 4 - (((ev_uintptr_t)b) & 3);
    1.31 + 		memcpy(b, &u, n_bytes);
    1.32 + 		b += n_bytes;
    1.33 + 		n -= n_bytes;

mercurial