[PATCH libICE] Use arc4random when available to produce the auth cookie.

Alan Coopersmith alan.coopersmith at oracle.com
Thu Sep 5 22:52:43 PDT 2013


On 09/ 4/13 12:40 AM, Matthieu Herrb wrote:
> @@ -58,6 +62,9 @@ IceGenerateMagicCookie (
>       if ((auth = malloc (len + 1)) == NULL)
>   	return (NULL);
>
> +#ifdef HAVE_ARC4RANDOM_BUF
> +    arc4random_buf(auth, len);
> +#else
>   #ifdef ITIMER_REAL
>       {
>   	struct timeval  now;
> @@ -79,8 +86,8 @@ IceGenerateMagicCookie (
>   	value = rand ();
>   	auth[i] = value & 0xff;
>       }
> +#endif
>       auth[len] = '\0';
> -
>       return (auth);
>   }

Won't that cause unused variable warnings for ldata, seed, value, & i,
which are now only used in the #else clause?   Can you wrap their
variable declarations in #ifndef HAVE_ARC4RANDOM_BUF?

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list