From 5afa0d9b2e14194d34001a24007d96536608e651 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 13 Mar 2007 14:16:08 +0100 Subject: [PATCH 1/1] 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 --- io_u.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/io_u.c b/io_u.c index 10fa188d..fead400c 100644 --- a/io_u.c +++ b/io_u.c @@ -109,6 +109,9 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u) 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)); -- 2.25.1