Re: [Boost-bugs] [Boost C++ Libraries] #5187: uuid\seed_rng.hpp sha1_random_digest_state_ not random

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5187: uuid\seed_rng.hpp sha1_random_digest_state_ not random
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-10 01:47:26


#5187: uuid\seed_rng.hpp sha1_random_digest_state_ not random
--------------------------------------------+-------------------------------
  Reporter: qiaozhiqiang@… | Owner: atompkins
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: uuid
   Version: Boost 1.45.0 | Severity: Problem
Resolution: invalid | Keywords: seed_rng
--------------------------------------------+-------------------------------

Comment (by qiaozhiqiang@…):

 {{{

 "{{{sha.process_bytes( (unsigned char const*)&ps, sizeof( ps ) );}}}
  does not use the value of {{{ps}}}, but the address of {{{ps}}},
 {{{&ps}}}, which is a value on the stack since this is a local variable."

 no, sha.process_bytes is use the ps value [4 bytes] pass by pointer.
  but ps value [address of static unsigned int state[5] ] will be
 different in different program, different build, different module,
 different DLL...

 see comment:3 Changed 19 months ago by anonymous

 ////////////////////

 "Thus the values in the static unsigned int state[5]; are not constant for
  the duration of the program. So at worst it is initialized to zero, at
 best
 it does contain random data initially."

 static unsigned int state[5] is a static function variable will be always
 initialized to zero in ISO C or ISO C++, static unsigned int state[5] ===
  static unsigned int state[5] = {0,0,0,0,0}



 so, Yes, the code is correct.
 but the comments "// intentionally left uninitialized" is not correct.

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5187#comment:6>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC