Skip to content

Fix version mask unvalid len#2109

Merged
plebhash merged 2 commits intostratum-mining:mainfrom
exd02:fix/version-mask-unvalid-len
Mar 5, 2026
Merged

Fix version mask unvalid len#2109
plebhash merged 2 commits intostratum-mining:mainfrom
exd02:fix/version-mask-unvalid-len

Conversation

@exd02
Copy link
Contributor

@exd02 exd02 commented Mar 4, 2026

Fixes #2108

This PR introduces a new error variant, Error::InvalidHexLen, to handle cases where mining.set_version_mask exceeds 8 bytes, which previously resulted in an underflow.

The validation is added in HexU32Be::try_from, returning InvalidHexLen when the input length is greater than the expected 8 hex characters.

A test is included to ensure that a mining.set_version_mask message with a length greater than 8 bytes fails with ParsingMethodError::InvalidHexLen.

@exd02 exd02 force-pushed the fix/version-mask-unvalid-len branch from bc0bf1f to 1fbc1d8 Compare March 4, 2026 15:39
@exd02 exd02 force-pushed the fix/version-mask-unvalid-len branch 3 times, most recently from 08d0596 to 1fbc1d8 Compare March 4, 2026 23:26
exd02 added 2 commits March 4, 2026 20:26
This test causes panic before the previous commit fix. This crash was
caused by an underflow integer bug, where the length the version mask
was greater than 8 bytes in the utils.rs:try_from function.
@exd02 exd02 force-pushed the fix/version-mask-unvalid-len branch from 1fbc1d8 to 5a7b415 Compare March 4, 2026 23:27
@plebhash plebhash merged commit 2c70113 into stratum-mining:main Mar 5, 2026
14 checks passed
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.

subtraction underflow occurs when mining.set_version_mask is greater then 8 bytes

3 participants