From 3373249974e7e280df48bc16045748b77fef7942 Mon Sep 17 00:00:00 2001 From: Dongmao Zhang Date: Fri, 30 Jan 2015 11:20:50 +0800 Subject: [PATCH] Fix ReplicatedPG do_xattr_cmp_u64 1. bufferlist.c_str() will return a string which is longer than its real length. This could cause an error result from do_xattr_cmp_u64. So use std::string to receive the xattr 2. s/atoll/strtoull Signed-off-by: Dongmao Zhang --- src/osd/ReplicatedPG.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 30638cc7608d..42bf87ea80f2 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -3009,8 +3009,10 @@ void ReplicatedPG::snap_trimmer() int ReplicatedPG::do_xattr_cmp_u64(int op, __u64 v1, bufferlist& xattr) { __u64 v2; - if (xattr.length()) - v2 = atoll(xattr.c_str()); + + string v2s(xattr.c_str(), xattr.length()); + if (v2s.length()) + v2 = strtoull(v2s.c_str(), NULL, 10); else v2 = 0; -- 2.47.3