rbd: fix crash with zero sized image
authorPan Liu <pan.liu@istuary.com>
Sat, 12 Nov 2016 15:26:57 +0000 (23:26 +0800)
committerJens Axboe <axboe@fb.com>
Sat, 12 Nov 2016 15:36:23 +0000 (08:36 -0700)
When the user create a rbd image with size zero, and specify the
"size" larger than zero in fio option, rbd will crash.

Signed-off-by: Pan Liu <pan.liu@istuary.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
engines/rbd.c

index aa50c801c3c831eec13a5c212fdc836c7f85e675..ee2ce813b9ae2d6e3bb2ac3649a9e909573ea7f0 100644 (file)
@@ -595,7 +595,12 @@ static int fio_rbd_setup(struct thread_data *td)
        if (r < 0) {
                log_err("rbd_status failed.\n");
                goto disconnect;
+       } else if (info.size == 0) {
+               log_err("image size should be larger than zero.\n");
+               r = -EINVAL;
+               goto disconnect;
        }
+
        dprint(FD_IO, "rbd-engine: image size: %lu\n", info.size);
 
        /* taken from "net" engine. Pretend we deal with files,