From 30dec3ee14e5c4ad694506ef27e3f6bb4de999bc Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 29 Apr 2021 09:44:05 +0800 Subject: [PATCH] crimson/onode-staged-tree: fix potential overflow in toMatchKindCMP() Signed-off-by: Yingxin Cheng --- .../os/seastore/onode_manager/staged-fltree/fwd.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h b/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h index 890e1fcd08c..65aa3bf806b 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/fwd.h @@ -73,8 +73,13 @@ inline MatchKindCMP toMatchKindCMP(int value) { } template MatchKindCMP toMatchKindCMP(const Type& l, const Type& r) { - int match = l - r; - return toMatchKindCMP(match); + if (l > r) { + return MatchKindCMP::GT; + } else if (l < r) { + return MatchKindCMP::LT; + } else { + return MatchKindCMP::EQ; + } } inline MatchKindCMP toMatchKindCMP( -- 2.39.5