heimdal/heimdal — pull request #61 by kaduk (2014-02-07 20:52:22+00:00)
Title: fortuna: handle gettimeofday() failure

gettimeofday() is allowed to fail; in particular it is likely to
do so in a standalone or kernel environment, where the routine may
be a stub that always fails.

In such cases, without this check, we will not reseed() in the
st->reseed_count == 0 case in extract_data() (i.e., the first time
we need to produce output). This results in attempting to perform
an encryption operation with st->ciph uninitialized, in particular
with 'rounds' set to zero. This causes the loop termination check
("--r == 0") in rijndaelEncrypt() to fail, which eventually leads
to an attempt to access unmapped memory as array indices grow too
large.

When we cannot usefully tell if enough time has passed, we must
be conservative and assume that enough time has passed, allowing
the reseed to continue.