On Thu, Feb 18, 2016 at 09:11:18PM +0100, Stefan Kempf wrote:
>  
> I think we don't mix declarations and code.
> Would this be an option?
> 
> diff --git a/dev/rnd.c b/dev/rnd.c
> index 819ce0d..0f57b1b 100644
> --- a/dev/rnd.c
> +++ b/dev/rnd.c
> @@ -421,7 +421,7 @@ add_entropy_words(const u_int32_t *buf, u_int n)
>  
>       for (; n--; buf++) {
>               u_int32_t w = (*buf << entropy_input_rotate) |
> -                 (*buf >> (32 - entropy_input_rotate));
> +                 (*buf >> ((32 - entropy_input_rotate) & 31));
>               u_int i = entropy_add_ptr =
>                   (entropy_add_ptr - 1) & POOLMASK;
>               /*

Yes, that should do.

>  
> > Index: dev/rnd.c
> > ===================================================================
> > RCS file: /cvs/src/sys/dev/rnd.c,v
> > retrieving revision 1.178
> > diff -u -p -u -r1.178 rnd.c
> > --- dev/rnd.c       8 Jan 2016 07:54:02 -0000       1.178
> > +++ dev/rnd.c       31 Jan 2016 10:11:17 -0000
> > @@ -420,8 +420,9 @@ add_entropy_words(const u_int32_t *buf, 
> >     };
> >  
> >     for (; n--; buf++) {
> > -           u_int32_t w = (*buf << entropy_input_rotate) |
> > -               (*buf >> (32 - entropy_input_rotate));
> > +           u_int32_t w = *buf << entropy_input_rotate;
> > +           if (entropy_input_rotate > 0)
> > +                   w |= *buf >> (32 - entropy_input_rotate);
> >             u_int i = entropy_add_ptr =
> >                 (entropy_add_ptr - 1) & POOLMASK;
> >             /*
> > 
> > cheers,
> > natano
> > 

Reply via email to