apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Bowling <b_j...@dreamarts.co.jp>
Subject UUID get_current_time Problem
Date Mon, 02 Sep 2013 01:03:58 GMT
After doing a bit of digging through the source code, a co-worker of 
mine (Bai Dongqiang) found something that might not be bad enough to be 
classified as a bug, but should probably be fixed anyway.  The problem 
is that it is possible for the same value to be returned by 
get_current_time() in getuuid.c which could then theoretically cause the 
generated UUID to be the same. He found this in 1.5.2, but it is 
probably also in previous versions as well.

We know that the timestamp resolution is actually 1/10 of a microsecond, 
but for the sake of explanation, let's assume that the microsecond used 
in get_current_time() went in the order of 1, 1, 2.  The values returned 
would be 1, 2, 2 respectively when it should be 1, 2, 3.  The quick and 
easy fix for this would be to alter the if statement on line 161 from 
`time_last + fudge > time_now` to `time_last + fudge >= time_now`.

He looped through get_current_time() 10 million times to confirm his 
suspicions and it has in fact returned the same value.  The UUID however 
was always different, but this seems to be caused by the fact that the 
memcpy statement in apr_uuid_get actually takes about 5 microseconds, 
fudging the results a bit.

Not sure if this should be considered a bug or not so I figured I'd post 
it in the mailing list and see how it went.

Thanks


Mime
View raw message