Obscure file randommap fix
If file size < block and no size is given, we could be generating
a random offset within -1 and deref ->file_map[] beyond its size.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/io_u.c b/io_u.c
index 10fa188..fead400 100644
--- a/io_u.c
+++ b/io_u.c
@@ -109,6 +109,9 @@
unsigned long long max_blocks = f->file_size / td->min_bs[ddir];
int loops = 5;
+ if (!max_blocks)
+ return 1;
+
do {
r = os_random_long(&td->random_state);
b = ((max_blocks - 1) * r / (unsigned long long) (RAND_MAX+1.0));