Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid an underflow in Ledger BIP32 path parsing (#6482)
Description --- Avoids a possible underflow in Ledger BIP32 path parsing. Motivation and Context --- The Ledger application code includes `TryFrom<&[u8]>` parsing for BIP32 paths that is intended to return an error on an empty slice. However, the initial path length computation will underflow if this occurs. While this won't panic in release mode, it would almost certainly fail an unrelated check that the path length does not exceed a generic maximum, instead of triggering a subsequent test that the input slice is not empty. This almost certainly would not result in unintended behavior, and would return an error. However, it has a bad code smell. This PR moves the empty slice check so it is done prior to computing the path length, in order to ensure that no underflow occurs. How Has This Been Tested? --- No automated testing appears to exist for this. What process can a PR reviewer use to test or verify this change? --- Check that the underflow condition can no longer occur.
- Loading branch information