Repository navigation
fix(utility): read an odd number of hex digits as a leading zero nibble - #5966
Open
Dev-next-gen wants to merge 1 commit into
Open
Dev-next-gen wants to merge 1 commit into
Dev-next-gen wants to merge 1 commit into
Conversation
from_hex sized its buffer as digit_count / 2, so the leading digit of an odd-length value was dropped. A config value such as min_threads = 0x8 parsed as 0, and keybindings = [0x9, 0xA0] mapped key 0 instead of 0x9.
Contributor
Author
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
util::from_hexsized its output asdigit_count / 2, so when a value had an odd number of hex digits the leading digit was dropped. Through the config parser (parse_config_integerandlist_int_f), this gives:min_threads = 0x8is parsed as0keybindings = [0x9, 0xA0]maps key0to0xA0instead of key0x9keybindings = [0x1B, 0x123]maps0x1Bto0x23instead of0x123The fix rounds the byte count up and treats the missing high nibble of the last byte as zero, so an odd-length value reads as if it had a leading
0. Even-length input and the existing truncation of over-long input are unchanged. The pairing salt is the only other caller and always passes exactly 32 digits.Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
Added
UtilityFromHexTests.OddDigitCountReadsTheLeadingDigitAsTheHighNibble("8","ABC"in both byte orders,"1:2:3"with separators).I built
test_sunshineon Linux (Ubuntu 26.04, Debug) and ran--gtest_filter=UtilityFromHexTests.*:ConfigPersistenceTest.*, together with a local, uncommitted config test that appliesmin_threads = 0x8andkeybindings = [0x9, 0xA0, 0x1B, 0x123]throughconfig::apply_config_for_test:from_hex<uint32_t>("8")is0,min_threadsis0, there is no binding for0x9, and0x1Bmaps to35)I did not run the Windows or macOS builds.
Type of Change
Checklist
AI Usage
See our AI usage policy.
Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.