From: Aleksei Gutikov Date: Mon, 21 Aug 2017 14:04:45 +0000 (+0300) Subject: rgw: Prevent overflow of stats cached values X-Git-Tag: v10.2.10~54^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F16720%2Fhead;p=ceph.git rgw: Prevent overflow of stats cached values Signed-off-by: Pavan Rallabhandi Fixes: http://tracker.ceph.com/issues/20934 Signed-off-by: Aleksei Gutikov (cherry picked from commit 634215eea1ddd4e4f5dc0066c4a2e745cfc20475) Conflicts: src/rgw/rgw_quota.cc Have the quota stats structures to reflect rounded values in KB and honor the signed integer values --- diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 1153639184e9..dc880b4bd0d8 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -221,19 +221,19 @@ public: uint64_t rounded_kb_added = rgw_rounded_objsize_kb(added_bytes); uint64_t rounded_kb_removed = rgw_rounded_objsize_kb(removed_bytes); - if ((entry->stats.num_kb_rounded + rounded_kb_added - rounded_kb_removed) >= 0) { + if (((int64_t)(entry->stats.num_kb_rounded + rounded_kb_added - rounded_kb_removed)) >= 0) { entry->stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed); } else { entry->stats.num_kb_rounded = 0; } - if ((entry->stats.num_kb + ((added_bytes - removed_bytes) / 1024)) >= 0) { + if (((int64_t)(entry->stats.num_kb + ((added_bytes - removed_bytes) / 1024))) >= 0) { entry->stats.num_kb += (added_bytes - removed_bytes) / 1024; } else { entry->stats.num_kb = 0; } - if ((entry->stats.num_objects + objs_delta) >= 0) { + if (((int64_t)(entry->stats.num_objects + objs_delta)) >= 0) { entry->stats.num_objects += objs_delta; } else { entry->stats.num_objects = 0;