From ba095c85664a4d0c731c1ac870592a92ba9b7793 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Thu, 12 Apr 2018 09:02:06 +0200 Subject: [PATCH] Avoid using signed integers for edge IDs --- CHANGELOG.md | 5 +++++ CMakeLists.txt | 2 +- include/util/dynamic_graph.hpp | 9 ++++++++- package.json | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d617811..cd152c434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 5.16.6 + - Changes from 5.16.5: + - Bugfixes: + - FIXED: integer overflow in `DynamicGraph::Renumber` [#5021](https://github.com/Project-OSRM/osrm-backend/pull/5021) + # 5.16.5 - Changes from 5.16.4: - Debug: diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e0ae5b7b..a54009648 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ endif() project(OSRM C CXX) set(OSRM_VERSION_MAJOR 5) set(OSRM_VERSION_MINOR 16) -set(OSRM_VERSION_PATCH 5) +set(OSRM_VERSION_PATCH 6) set(OSRM_VERSION "${OSRM_VERSION_MAJOR}.${OSRM_VERSION_MINOR}.${OSRM_VERSION_PATCH}") add_definitions(-DOSRM_PROJECT_DIR="${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/include/util/dynamic_graph.hpp b/include/util/dynamic_graph.hpp index f2a3d8b3b..163bb8629 100644 --- a/include/util/dynamic_graph.hpp +++ b/include/util/dynamic_graph.hpp @@ -2,6 +2,8 @@ #define DYNAMICGRAPH_HPP #include "util/deallocating_vector.hpp" +#include "util/exception.hpp" +#include "util/exception_utils.hpp" #include "util/integer_range.hpp" #include "util/permutation.hpp" #include "util/typedefs.hpp" @@ -424,7 +426,7 @@ template class DynamicGraph util::inplacePermutation(node_array.begin(), node_array.end(), old_to_new_node); // Build up edge permutation - auto new_edge_index = 0; + EdgeID new_edge_index = 0; std::vector old_to_new_edge(edge_list.size(), SPECIAL_EDGEID); for (auto node : util::irange(0, number_of_nodes)) { @@ -432,6 +434,11 @@ template class DynamicGraph // move all filled edges for (auto edge : GetAdjacentEdgeRange(node)) { + if (new_edge_index == std::numeric_limits::max()) + { + throw util::exception("There are too many edges, OSRM only supports 2^32" + + SOURCE_REF); + } edge_list[edge].target = old_to_new_node[edge_list[edge].target]; BOOST_ASSERT(edge_list[edge].target != SPECIAL_NODEID); old_to_new_edge[edge] = new_edge_index++; diff --git a/package.json b/package.json index bd8f7e623..3c6ec1f1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "osrm", - "version": "5.16.5", + "version": "5.16.6", "private": false, "description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.", "dependencies": {