[Xorp-cvs] XORP cvs commit: xorp/libxorp
Pavlin Radoslavov
pavlin at ICSI.Berkeley.EDU
Tue Apr 22 10:19:55 PDT 2008
> >> Modified files:
> >> libxorp random.c Log message:
> >> Fix an uninitialized variable warning in gcc 4.2.
> >>
> >> Obtained from: XORP/OLSR
> >> Sponsored by: CenGen, Inc.
> >>
> >> Revision Changes Path
> >> 1.15 +2 -2; commitid: e598480de48141a7; xorp/libxorp/random.c
> >>
> >
> > Bruce,
> >
> > The above commit fixes the compilation error, but doesn't fix the
> > problem.
> > In the original code, variable "junk_seed" has been intentionally
> > left uninitialized so when used it will increase the
> > unpredictability in the randomness.
> > In fact, "junk_seed" has been used to feed the unpredicted value
> > into variable "junk" as a compiler work-around.
> > Is there any way to rewrite the code to keep the gcc-4.2 compiler
> > happy and keep junk_seed unintialized?
> > E.g., maybe by using a pointer to "junk_seed" or an array of 1-2
> > elements of type "long" or something like this.
> >
> That's a scary way to get randomness (these things are usually the same
> between each
> start of the system, I have found)...maybe pull from a /dev/random or similar
> things on other OS?
No, we don't relay on the uninitalized value itself only the get the
randomness.
Actually, inside libxorp/random.c we are using /dev/random :)
The uninitialized "junk" variable in combination with
gettimeofday() and getpid() is used in case /dev/random doesn't
exist. Note that the "junk" variable is allocated on the stack,
so it might or might not add some additional unpredictability.
Regards,
Pavlin
More information about the Xorp-cvs
mailing list