aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/shuf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index 9f61f2f7d..217f15c97 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -53,7 +53,7 @@ static void shuffle_lines(char **lines, unsigned numlines)
/* RAND_MAX can be as small as 32767 */
if (i > RAND_MAX)
r ^= rand() << 15;
- r %= i;
+ r %= i + 1;
tmp = lines[i];
lines[i] = lines[r];
lines[r] = tmp;