Re: Hash collision vectors in APR?

2012-01-13 Thread Bojan Smojver
On Thu, 2012-01-12 at 19:58 -0800, Chris Darroch wrote: +if (strcmp(DEV_RANDOM, /dev/random) != 0 +apr_generate_random_bytes((unsigned char *)ht-seed, + sizeof(ht-seed)) != APR_SUCCESS) This probably wouldn't work as expected. If you had

Re: Hash collision vectors in APR?

2012-01-13 Thread Bojan Smojver
On Fri, 2012-01-13 at 19:57 +1100, Bojan Smojver wrote: This probably wouldn't work as expected. If you had /dev/random selected for DEV_RANDOM, the if would fail and srand()/rand() bit would never get called. No? Like attached maybe? -- Bojan Index: tables/apr_hash.c

Re: Hash collision vectors in APR?

2012-01-13 Thread Philip Martin
Chris Darroch chr...@pearsoncmg.com writes: The other question, I suppose, is whether there's a hit to performance from apr_generate_random_bytes() call. Without having tested explicitly, it looks like the default case for modern Linux is APR_HAS_RANDOM=1 and DEV_RANDOM=/dev/random, with

Re: Hash collision vectors in APR?

2012-01-13 Thread Chris Darroch
Bojan Smojver wrote: On Fri, 2012-01-13 at 19:57 +1100, Bojan Smojver wrote: This probably wouldn't work as expected. If you had /dev/random selected for DEV_RANDOM, the if would fail and srand()/rand() bit would never get called. No? Like attached maybe? Yes, that looks better than

Re: Hash collision vectors in APR?

2012-01-13 Thread Chris Darroch
Philip Martin wrote: I'm not sure how Linux distributors configure things, but APR itself defaults to /dev/urandom. Yup, Bojan corrected me on that too! I don't think apr_hash_make should be trying to second guess apr_generate_random_bytes. I suppose my strong hesitation about handing

Re: Hash collision vectors in APR?

2012-01-13 Thread Bojan Smojver
--- Original message --- From: Chris Darroch I'd personally rather see the use of it dropped entirely in all cases and the code Bojan worked on as the fallback case always used, since it adds no significant complexity and appears in line with other solutions, such as the one in