]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: ceph-monstore-tool: validate start/stop vals 3274/head
authorJoao Eduardo Luis <joao@redhat.com>
Mon, 29 Dec 2014 17:25:58 +0000 (17:25 +0000)
committerJoao Eduardo Luis <joao@redhat.com>
Mon, 29 Dec 2014 17:50:28 +0000 (17:50 +0000)
on commands that use 'start' and 'stop'/'end' values, we should validate
them and inform the user when 'stop' > 'start'.

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
src/tools/ceph_monstore_tool.cc

index d643411efe304ed6c0aca83ddbe91dc797e3fb29..65cddb462ab45a530168726843d37286653095e5 100644 (file)
@@ -426,6 +426,14 @@ int main(int argc, char **argv) {
       goto done;
     }
 
+    if (dstart > dstop) {
+      std::cerr << "error: 'start' version (value: " << dstart << ") "
+                << " is greater than 'end' version (value: " << dstop << ")"
+                << std::endl;
+      err = EINVAL;
+      goto done;
+    }
+
     version_t v = dstart;
     for (; v <= dstop; ++v) {
       bufferlist bl;
@@ -487,6 +495,14 @@ int main(int argc, char **argv) {
       goto done;
     }
 
+    if (dstart > dstop) {
+      std::cerr << "error: 'start' version (value: " << dstart << ") "
+                << " is greater than 'stop' version (value: " << dstop << ")"
+                << std::endl;
+      err = EINVAL;
+      goto done;
+    }
+
     TraceIter iter(outpath.c_str());
     iter.init();
     while (true) {