]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: don't get inc osdmap name truncated
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 6 May 2016 08:40:18 +0000 (16:40 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 11 May 2016 02:15:42 +0000 (10:15 +0800)
By definition, epoch_t is of type __u32 and shall allow
13 epochs/second for 10 years. The biggest epoch we can
ever see is 4294967296, which is 10 chars long.
However, by declaring "char foo[20];" here, we leave
8 chars (20 - 11("inc_osdmap.") - 1('\0') = 8) for the
epoch field only, so the epoch will get truncated when
it becomes big enough, which is unsafe.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/OSD.h

index cdf2afd45dc231d3aa1bb1da98956d05d282df42..c2ff47e7e7b441be55b08d5d0206fb8fdda8d121 100644 (file)
@@ -1146,7 +1146,7 @@ public:
     return ghobject_t(hobject_t(sobject_t(object_t(foo), 0)));
   }
   static ghobject_t get_inc_osdmap_pobject_name(epoch_t epoch) {
-    char foo[20];
+    char foo[22];
     snprintf(foo, sizeof(foo), "inc_osdmap.%d", epoch);
     return ghobject_t(hobject_t(sobject_t(object_t(foo), 0)));
   }