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

Matthieu Herrb matthieu.herrb at laas.fr
Thu Sep 5 23:44:28 PDT 2013


On Thu, Sep 05, 2013 at 10:52:43PM -0700, Alan Coopersmith wrote:
> 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?

Sure. New version sent.

-- 
Matthieu Herrb


More information about the xorg-devel mailing list