diff options
-rw-r--r-- | coreutils/shuf.c | 2 |
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) | |||
53 | /* RAND_MAX can be as small as 32767 */ | 53 | /* RAND_MAX can be as small as 32767 */ |
54 | if (i > RAND_MAX) | 54 | if (i > RAND_MAX) |
55 | r ^= rand() << 15; | 55 | r ^= rand() << 15; |
56 | r %= i; | 56 | r %= i + 1; |
57 | tmp = lines[i]; | 57 | tmp = lines[i]; |
58 | lines[i] = lines[r]; | 58 | lines[i] = lines[r]; |
59 | lines[r] = tmp; | 59 | lines[r] = tmp; |