From: Aleksei Gutikov Date: Mon, 21 Aug 2017 14:04:45 +0000 (+0300) Subject: rgw: Prevent overflow of stats cached values X-Git-Tag: v13.0.0~41^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17116%2Fhead;p=ceph.git rgw: Prevent overflow of stats cached values Fixes: http://tracker.ceph.com/issues/20934 Signed-off-by: Aleksei Gutikov --- diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 8e050a0592d..d94dc0ca4cf 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -241,19 +241,19 @@ public: const uint64_t rounded_added = rgw_rounded_objsize(added_bytes); const uint64_t rounded_removed = rgw_rounded_objsize(removed_bytes); - if ((entry->stats.size + added_bytes - removed_bytes) >= 0) { + if (((int64_t)(entry->stats.size + added_bytes - removed_bytes)) >= 0) { entry->stats.size += added_bytes - removed_bytes; } else { entry->stats.size = 0; } - if ((entry->stats.size_rounded + rounded_added - rounded_removed) >= 0) { + if (((int64_t)(entry->stats.size_rounded + rounded_added - rounded_removed)) >= 0) { entry->stats.size_rounded += rounded_added - rounded_removed; } else { entry->stats.size_rounded = 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;