From 634215eea1ddd4e4f5dc0066c4a2e745cfc20475 Mon Sep 17 00:00:00 2001 From: Aleksei Gutikov Date: Mon, 21 Aug 2017 17:04:45 +0300 Subject: [PATCH] rgw: Prevent overflow of stats cached values Fixes: http://tracker.ceph.com/issues/20934 Signed-off-by: Aleksei Gutikov --- src/rgw/rgw_quota.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 8e050a0592d6..d94dc0ca4cf7 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; -- 2.47.3