]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Replace hand-rolled modulo with arc4random_uniform.
authorDarren Tucker <dtucker@dtucker.net>
Thu, 25 Sep 2025 22:23:21 +0000 (08:23 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Thu, 25 Sep 2025 22:23:21 +0000 (08:23 +1000)
Fixes potential modulo-by-zero UB flagged by Coverity CID 405068

regress/netcat.c

index 0acedfd82493b6aafb62f5a9abf8997b4697053d..c6211178063678110ab5e200d6fd38c04b35bf08 100644 (file)
@@ -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;