提交 0a5a6f0d 编写于 作者: M Michal Privoznik

virrandom: Avoid undefined behaviour in virRandomBits

If nbits is 64 (or greater) then shifting 1ULL left is undefined.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 1c701c47
......@@ -68,7 +68,9 @@ uint64_t virRandomBits(int nbits)
return 0;
}
if (nbits < 64)
ret &= (1ULL << nbits) - 1;
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册