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

[1.0.1] Verify index >= 0 in apply_diff and fix warnings #722

Merged
merged 7 commits into from
Sep 10, 2024

Conversation

linh2931
Copy link
Member

@linh2931 linh2931 commented Sep 9, 2024

index in apply_diff can be a signed int and can be negative. Currently index is only checked not greater than the size.

This also results in warnings in numerous places as apply_diff is in a header file which is included by a number of files:

libraries/libfc/include/fc/container/ordered_diff.hpp:111:35: warning: comparison of integer expressions of different signedness: ‘std::ptrdiff_t’ {aka ‘long int’} and ‘std::vector<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
...
ibraries/libfc/include/fc/container/ordered_diff.hpp:119:26: warning: comparison of integer expressions of different signedness: ‘std::tuple_element<0, std::pair<int, char> >::type’ {aka ‘int’} and ‘std::vector<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

Resolves #723

@linh2931 linh2931 requested review from heifner and greg7mdp September 9, 2024 14:20
@arhag arhag linked an issue Sep 9, 2024 that may be closed by this pull request
@linh2931 linh2931 requested review from heifner and arhag September 10, 2024 01:55
@ericpassmore
Copy link
Contributor

Note:start
category: Chores
component: Internal
summary: Assert non-negative index in apply_diff.
Note:end

@linh2931 linh2931 merged commit e5c0ee0 into release/1.0 Sep 10, 2024
36 checks passed
@linh2931 linh2931 deleted the check_negative branch September 10, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stricter checks in apply_diff and compile warnings
5 participants