From: Darren Tucker Date: Thu, 25 Sep 2025 22:23:21 +0000 (+1000) Subject: Replace hand-rolled modulo with arc4random_uniform. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c3c9f03c3c2cc4e40decbb49b8486abfb9e57df;p=thirdparty%2Fopenssh-portable.git Replace hand-rolled modulo with arc4random_uniform. Fixes potential modulo-by-zero UB flagged by Coverity CID 405068 --- diff --git a/regress/netcat.c b/regress/netcat.c index 0acedfd82..c62111780 100644 --- a/regress/netcat.c +++ b/regress/netcat.c @@ -1134,7 +1134,7 @@ build_ports(char *p) char *c; for (x = 0; x <= (hi - lo); x++) { - y = (arc4random() & 0xFFFF) % (hi - lo); + y = arc4random_uniform(hi - lo); c = portlist[x]; portlist[x] = portlist[y]; portlist[y] = c;