Re: Is fork() hook ever possible?

From: Andrey Chernov <ache_at_FreeBSD.ORG>
Date: Tue, 15 Nov 2011 06:39:12 +0400
On Tue, Nov 15, 2011 at 02:11:03AM +0100, Oliver Pinter wrote:
> > P.S. Do I answer your doubts about &rdat key initialization in my prev.
> > posting?
> 
> I think it's a much correct solution, rather than the original patch,
> while it initializes the whole structure, not only the key array...
> (&rdat.key vs &rdat; and uninitialized pid and tv):
> 
>  	fd = _open(RANDOMDEV, O_RDONLY, 0);
>  	done = 0;
>  	if (fd >= 0) {
> -		if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
> +		if (_read(fd, &rdat, sizeof(rdat)) == sizeof(rdat))
>  			done = 1;
>  		(void)_close(fd);
> -	}
> +	}
> 

Currently this change will have no any effect in the code because only 
first 128 bytes of the structure are passed later:

arc4_addrandom((u_char *)&rdat, KEYSIZE);

In case you mean passing later whole structure like:

arc4_addrandom((u_char *)&rdat, sizeof(rdat));

it will be incorrect because it change known algorithm parameters, which 
defines exact 128 bytes and not anything else.

-- 
http://ache.vniz.net/
Received on Tue Nov 15 2011 - 01:39:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:20 UTC