Replace hand-rolled modulo with arc4random_uniform.
Fixes potential modulo-by-zero UB flagged by Coverity CID 405068
This commit is contained in:
1 file changed
+1
-1
+1
-1
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user