Skip to content

Commit adce17c

Browse files
authored
Fix potential integer overflow in shortest path est (#22150)
* Add runtime check for overflow. * CHANGELOG.
1 parent 0f2dd6a commit adce17c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
devel
22
-----
33

4+
* Fix a potential integer overflow in shortest path estimation.
5+
46
* Fix BTS-2268: Fixed an issue where query plan for queries with subquery
57
is causing a crash when being stored in query plan cache. The issue
68
is a missing invalidateCost from the splice-subqueries rule.

arangod/Graph/ShortestPathOptions.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ double ShortestPathOptions::estimateCost(size_t& nrItems) const {
170170
// We use the "seven-degrees-of-seperation" rule.
171171
// This theory asumes that the shortest path is at most 7 steps of length
172172

173-
nrItems = static_cast<size_t>(std::pow(baseCreateItems, 7));
173+
double tmp = std::pow(baseCreateItems, 7);
174+
nrItems = tmp > static_cast<double>(std::numeric_limits<size_t>::max())
175+
? std::numeric_limits<size_t>::max()
176+
: static_cast<size_t>(tmp);
174177
return std::pow(baseCost, 7);
175178
}
176179

0 commit comments

Comments
 (0)