From 44b102f9e2e2acb854899903557068482afdf0fa Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 1 Sep 2016 14:18:55 -0400 Subject: [PATCH] SQUASH: mds/client: don't get clever with ceph_mds_request_head_legacy encode/decode As requested by Greg... Declare a legacy object on the stack, and do an extra copy to/from it. Signed-off-by: Jeff Layton --- src/messages/MClientRequest.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 26f69f7f3ec7..00419ebb5aca 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -165,11 +165,10 @@ public: if (header.version >= 4) { ::decode(head, p); } else { - struct ceph_mds_request_head_legacy *old_mds_head = - (struct ceph_mds_request_head_legacy *)&(head.oldest_client_tid); - - ::decode(*old_mds_head, p); + struct ceph_mds_request_head_legacy old_mds_head; + ::decode(old_mds_head, p); + memcpy(&head.oldest_client_tid, &old_mds_head, sizeof(old_mds_head)); head.version = 0; /* Can't set the btime from legacy struct */ @@ -197,10 +196,10 @@ public: if (features & CEPH_FEATURE_FS_BTIME) { ::encode(head, payload); } else { - struct ceph_mds_request_head_legacy *old_mds_head = - (struct ceph_mds_request_head_legacy *)&(head.oldest_client_tid); + struct ceph_mds_request_head_legacy old_mds_head; - ::encode(*old_mds_head, payload); + memcpy(&old_mds_head, &(head.oldest_client_tid), sizeof(old_mds_head)); + ::encode(old_mds_head, payload); } ::encode(path, payload); -- 2.47.3