]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: validate order before creating an image
authorJosh Durgin <josh.durgin@inktank.com>
Fri, 8 Jun 2012 14:55:52 +0000 (07:55 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Fri, 8 Jun 2012 23:38:22 +0000 (16:38 -0700)
The value must be passed, and it shouldn't be below 4k
(enforced by the command line tool already) or above the
range expressible in the header.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/librbd.cc

index ebe7db2cd912e65cd83904e8d4751f46a45c2536..0d357fa222cb56c67f8cafcccf7d2e785bfa2192 100644 (file)
@@ -992,6 +992,14 @@ int create(IoCtx& io_ctx, const char *imgname, uint64_t size, int *order)
     return -EEXIST;
   }
 
+  if (!order)
+    return -EINVAL;
+
+  if (*order && (*order > 255 || *order < 12)) {
+    lderr(cct) << "order must be in the range [12, 255]" << dendl;
+    return -EDOM;
+  }
+
   uint64_t bid;
   string dir_info = RBD_INFO;
   r = rbd_assign_bid(io_ctx, dir_info, &bid);