rbd: Prevent Seg fault by checking read result in snap_read_header()

Signed-off-by: David Zafman <david.zafman@inktank.com>
This commit is contained in:
David Zafman 2014-04-03 13:01:11 -07:00
parent 9c6733e662
commit 409999c3b2

View File

@ -115,7 +115,11 @@ static int snap_read_header(cls_method_context_t hctx, bufferlist& bl)
if (rc < 0)
return rc;
if (bl.length() < sizeof(*header))
return -EINVAL;
header = (struct rbd_obj_header_ondisk *)bl.c_str();
assert(header);
if ((snap_count != header->snap_count) ||
(snap_names_len != header->snap_names_len)) {