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

types: make NewDecFromStr returns error for too large decimal #9157

Merged
merged 3 commits into from
Apr 22, 2021
Merged

types: make NewDecFromStr returns error for too large decimal #9157

merged 3 commits into from
Apr 22, 2021

Conversation

cuonglm
Copy link
Contributor

@cuonglm cuonglm commented Apr 21, 2021

Description

Otherwise, NewDecFromStr may accept very large input, causing Dec
methods panic, e.g Dec.TruncateInt

Found by oss-fuzz: https://oss-fuzz.com/testcase-detail/6454129938530304

Fixes #9160


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@cuonglm
Copy link
Contributor Author

cuonglm commented Apr 21, 2021

cc @odeke-em

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @cuonglm! Fruits of the tree of continuous fuzzing :-) @alessio @marbar3778 please help take a look and also we might need backports as this can crash a node.

types/decimal.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #9157 (491aaf7) into master (1a15412) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9157   +/-   ##
=======================================
  Coverage   58.89%   58.89%           
=======================================
  Files         585      585           
  Lines       32801    32803    +2     
=======================================
+ Hits        19318    19320    +2     
  Misses      11199    11199           
  Partials     2284     2284           
Impacted Files Coverage Δ
types/decimal.go 70.49% <100.00%> (+0.19%) ⬆️

Otherwise, NewDecFromStr may accept very large input, causing Dec
methods panic, e.g Dec.TruncateInt

Found by oss-fuzz: https://oss-fuzz.com/testcase-detail/6454129938530304

Fixes #9160
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

utACK

@alessio alessio merged commit e28271b into cosmos:master Apr 22, 2021
alessio pushed a commit that referenced this pull request Apr 22, 2021
alessio pushed a commit that referenced this pull request Apr 22, 2021
From: #9157
Closes: #9160

Co-authored-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
@odeke-em odeke-em deleted the cuonglm/validate-dec-coin-decimal branch April 22, 2021 14:03
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.

types: NewDecFromStr can return a Dec with too big decimal and panic
4 participants