Skip to content

Commit 6c3c9f0

Browse files
committed
Replace hand-rolled modulo with arc4random_uniform.
Fixes potential modulo-by-zero UB flagged by Coverity CID 405068
1 parent e914e61 commit 6c3c9f0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

regress/netcat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ build_ports(char *p)
11341134
char *c;
11351135

11361136
for (x = 0; x <= (hi - lo); x++) {
1137-
y = (arc4random() & 0xFFFF) % (hi - lo);
1137+
y = arc4random_uniform(hi - lo);
11381138
c = portlist[x];
11391139
portlist[x] = portlist[y];
11401140
portlist[y] = c;

0 commit comments

Comments
 (0)