Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using signed integers for edge IDs #5021

Merged
merged 1 commit into from
Apr 12, 2018
Merged

Avoid using signed integers for edge IDs #5021

merged 1 commit into from
Apr 12, 2018

Conversation

oxidase
Copy link
Contributor

@oxidase oxidase commented Apr 12, 2018

Issue

PR fixes an integer overflow if number of edges is greater than 2^31 and adds a check for an unsigned integer overflow.

Tasklist

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

@oxidase oxidase requested a review from TheMarex April 12, 2018 07:06
Copy link
Member

@TheMarex TheMarex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, good work tracking it down. 💯

@TheMarex TheMarex added this to the 5.16.6 milestone Apr 12, 2018
@oxidase oxidase merged commit 16abee1 into master Apr 12, 2018
@oxidase oxidase deleted the fix/int-overflow branch April 12, 2018 08:03
std::vector<EdgeID> old_to_new_edge(edge_list.size(), SPECIAL_EDGEID);
for (auto node : util::irange<NodeID>(0, number_of_nodes))
{
auto new_first_edge = new_edge_index;
// move all filled edges
for (auto edge : GetAdjacentEdgeRange(node))
{
if (new_edge_index == std::numeric_limits<EdgeID>::max())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this check be done before we start the loop and fail earlier? We know the size of the edge_list, right? This renumbering shouldn't create more than there was previously....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the check only prevents overflow of number_of_valid_edges, but you are right old_to_new_edge may be corrupted for dummy edges if new_edge_index overflows below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants