Skip to content

multi: Limit inputs to base58 decode.#2860

Merged
davecgh merged 4 commits intodecred:masterfrom
davecgh:multi_limit_inputs_to_base58_decode
Jan 1, 2022
Merged

multi: Limit inputs to base58 decode.#2860
davecgh merged 4 commits intodecred:masterfrom
davecgh:multi_limit_inputs_to_base58_decode

Conversation

@davecgh
Copy link
Copy Markdown
Member

@davecgh davecgh commented Dec 29, 2021

This modifies the following funcs that accept inputs which ultimately involve base58 decoding to reject any attempts to decode strings that are larger than the max possible size early since there is no reason to waste time and memory doing the base 58 decode when it is guaranteed to be invalid anyway:

  • stdaddr.DecodeAddressV0
  • hdkeychain.NewKeyFromString
  • dcrutil.DecodeWIF

It also adds associated tests to ensure proper functionality and includes a rework of the WIF tests in dcrutil to provide full coverage for both positive and negative paths, to test for the explicit reason for the failure to ensure that each test is actually testing the intended condition, and to make them more consistent with modern practices in the code.

@davecgh davecgh added this to the 1.8.0 milestone Dec 29, 2021
@davecgh davecgh changed the title Multi limit inputs to base58 decode multi: Limit inputs to base58 decode. Dec 29, 2021
Comment thread txscript/stdaddr/addressv0.go Outdated
@davecgh davecgh force-pushed the multi_limit_inputs_to_base58_decode branch 2 times, most recently from 6bc5aa9 to e002538 Compare December 31, 2021 18:23
This modifies DecodeAddressV0 to reject any attempts to decode strings
that are larger than the max possible size early since there is no
reason to waste time and memory doing the base 58 decode when it is
guaranteed to be invalid anyway.

It also adds an associated test to ensure proper functionality.
This modifies NewKeyFromString to reject any attempts to decode strings
that are larger than the max possible size early since there is no
reason to waste time and memory doing the base 58 decode when it is
guaranteed to be invalid anyway.

It also adds an associated test to ensure proper functionality.
This reworks the WIF tests to provide full coverage for both positive
and negative paths, to test for the explicit reason for the failure to
ensure that each test is actually testing the intended condition, and to
make them more consistent with modern practices in the code.
This modifies DecodeWIF to reject any attempts to decode strings that
are larger than the max possible size early since there is no reason to
waste time and memory doing the base 58 decode when it is guaranteed to
be invalid anyway.

It also adds an associated test to ensure proper functionality.
@davecgh davecgh force-pushed the multi_limit_inputs_to_base58_decode branch from e002538 to 2e8abf6 Compare January 1, 2022 09:09
@davecgh davecgh merged commit 2e8abf6 into decred:master Jan 1, 2022
@davecgh davecgh deleted the multi_limit_inputs_to_base58_decode branch January 1, 2022 09:13
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.

4 participants