On Fri, Jun 09, 2017 at 03:11:05PM +0200, Martin Pieuchot wrote:
> > The static variable last_zeroed does not look MP safe.  If I get
> > this code correctly it is only an optimization to avoid multiple
> > zeroing in addmask_key.  This does not work anyway with addmask_key
> > on the stack.
> 
> You're right, I removed the 'static'.

As last_zeroed is always 0 now, there is dead code left over.
I think this variable should be killed.

> @@ -438,8 +447,8 @@ rn_addmask(void *n_arg, int search, int 
>       }
>       if (m0 < last_zeroed)
>               memset(addmask_key + m0, 0, last_zeroed - m0);
> -     *addmask_key = last_zeroed = mlen;
> -     tm = rn_search(addmask_key, rn_masktop);
> +     SALEN(addmask_key) = mlen;

This assumes that addmask_key has been zeroed in rn_init().
I think now it must be
        memset(addmask_key + m0, 0, sizeof(addmask_key) - m0);
Maybe the sizeof(addmask_key) could be optimized by using mlen
or max_keylen instead.

bluhm

Reply via email to