On Thursday, 2 August 2018 09:56:49 CEST Bjoern Walk wrote: > Make the generation of random bits in virRandomBits independent of the > endianness of the running architecture. > > This also solves problems with the mocked random byte generation on > big-endian machines. > > Suggested-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> > Signed-off-by: Bjoern Walk <bwalk@xxxxxxxxxxxxx> > --- > This goes on top of Michal's fix: https://www.redhat.com/archives/libvir-list/2018-August/msg00080.html > > src/util/virrandom.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/util/virrandom.c b/src/util/virrandom.c > index 7915f653..26ff68f5 100644 > --- a/src/util/virrandom.c > +++ b/src/util/virrandom.c > @@ -34,6 +34,7 @@ > # include <gnutls/crypto.h> > #endif > > +#include "virendian.h" > #include "virrandom.h" > #include "virthread.h" > #include "count-one-bits.h" > @@ -61,13 +62,16 @@ VIR_LOG_INIT("util.random"); > uint64_t virRandomBits(int nbits) > { > uint64_t ret = 0; > + uint8_t val[8]; > > - if (virRandomBytes((unsigned char *) &ret, sizeof(ret)) < 0) { > + if (virRandomBytes((unsigned char *) &val, sizeof(val)) < 0) { > /* You're already hosed, so this particular non-random value > * isn't any worse. */ > return 0; > } > > + ret = virReadBufInt64LE(val); > + I do not think this patch is correct: we are dealing with random bytes, so there is no "endianness" for them. -- Pino Toscano
Attachment:
signature.asc
Description: This is a digitally signed message part.
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list