]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: does not crash if image header is too short 8785/head
authorKefu Chai <kchai@redhat.com>
Wed, 27 Apr 2016 16:59:34 +0000 (00:59 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 27 Apr 2016 16:59:44 +0000 (00:59 +0800)
if something goes wrong with the object, and returns a chunk shorter
than expected, don't panic

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/librbd/internal.cc

index 5276052c5190fd18f9031b27809082663c764625..dab665147c4f03b6282640617e0856df894ecfe9 100644 (file)
@@ -523,7 +523,8 @@ remove_mirroring_image:
       off += r;
     } while (r == READ_SIZE);
 
-    if (memcmp(RBD_HEADER_TEXT, header.c_str(), sizeof(RBD_HEADER_TEXT))) {
+    if (header.length() < sizeof(RBD_HEADER_TEXT) ||
+       memcmp(RBD_HEADER_TEXT, header.c_str(), sizeof(RBD_HEADER_TEXT))) {
       CephContext *cct = (CephContext *)io_ctx.cct();
       lderr(cct) << "unrecognized header format" << dendl;
       return -ENXIO;