On Thu, Aug 02, 2018 at 09:35:49AM +0200, Michal Privoznik wrote: > If nbits is 64 (or greater) then shifting 1ULL left is undefined. > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > src/util/virrandom.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/util/virrandom.c b/src/util/virrandom.c > index 3c011a8615..7915f6531e 100644 > --- a/src/util/virrandom.c > +++ b/src/util/virrandom.c > @@ -68,7 +68,9 @@ uint64_t virRandomBits(int nbits) > return 0; > } > > - ret &= (1ULL << nbits) - 1; > + if (nbits < 64) > + ret &= (1ULL << nbits) - 1; > + > return ret; > } Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list