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

Problem: insufficient validation of signed integers in CLI arguments #346

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

devashishdxt
Copy link
Collaborator

Solution: Changed types from signed to unsigned integers. Fixes #332.

@codecov
Copy link

codecov bot commented Jan 7, 2021

Codecov Report

Merging #346 (6129f3d) into master (32c3ed8) will decrease coverage by 0.01%.
The diff coverage is 17.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #346      +/-   ##
==========================================
- Coverage   12.13%   12.12%   -0.02%     
==========================================
  Files          32       32              
  Lines        5165     5171       +6     
==========================================
  Hits          627      627              
- Misses       4289     4295       +6     
  Partials      249      249              
Flag Coverage Δ
integration_tests 12.56% <17.64%> (-0.02%) ⬇️
unit_tests 5.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
x/chainmain/client/cli/genaccounts.go 12.39% <0.00%> (-0.65%) ⬇️
x/chainmain/client/cli/testnet.go 9.41% <33.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32c3ed8...6129f3d. Read the comment docs.

@@ -82,24 +82,30 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
if errstart != nil {
return fmt.Errorf("failed to parse vesting start: %w", errstart)
}
vestingStart, errstart := strconv.ParseInt(vestingStartStr, 10, 64)
vestingStartUint, errstart := strconv.ParseUint(vestingStartStr, 10, 64)
Copy link
Contributor

Choose a reason for hiding this comment

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

should the bitsize be 63 instead of 64 (as it's later casted to a signed int64)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to 32 to avoid overflow. Because we are converting it into int64 later.

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

not if this fix introduces potential overflows (when casting unsigned to signed numbers)

Solution: Changed types from signed to unsigned integers. Fixes crypto-org-chain#332.
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

the integration test failed -- https://github.com/crypto-com/chain-main/pull/346/checks?check_run_id=1660486167#step:5:380 --- I'll try to rerun it with the latest master merged

@tomtau tomtau self-requested a review January 7, 2021 05:47
@tomtau tomtau merged commit 7f03b8b into crypto-org-chain:master Jan 7, 2021
@devashishdxt devashishdxt deleted the issue-332 branch January 11, 2021 01:05
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.

Problem: insufficient validation of signed integers in CLI arguments
2 participants