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; } -- 2.16.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list