]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix assertion failure from arc4random_uniform with invalid limit
authorOndřej Surý <ondrej@isc.org>
Fri, 24 Oct 2025 08:34:33 +0000 (11:34 +0300)
committerOndřej Surý (GitLab job 6387727) <ondrej@isc.org>
Fri, 24 Oct 2025 20:23:32 +0000 (20:23 +0000)
commit97487d1abb23c7d40633b4971b7a6ce8656b7a3d
treee85dcd3e4975419e6aecd2ec2b2103fc5fe52615
parenta4f92e99e3e70bde27045dd4448bb95f8d31f342
Fix assertion failure from arc4random_uniform with invalid limit

When the arc4random_uniform() is called on NetBSD with upper_bound that
makes no sense statistically (0 or 1), the call crashes the calling
program.  Fix this by returning 0 when upper bound is < 2 as does Linux,
FreeBSD and NetBSD.  (Hint: System CSPRNG should never crash.)

(cherry picked from commit 871bce312b651cebe2da9fcfc4688f3b49f6895c)
lib/isc/include/isc/random.h