#5966

fix(utility): read an odd number of hex digits as a leading zero nibble

OpenDev-next-genwants to merge intofrom

Description

util::from_hex sized its output as digit_count / 2, so when a value had an odd number of hex digits the leading digit was dropped. Through the config parser (parse_config_integer and list_int_f), this gives:

  • min_threads = 0x8 is parsed as 0
  • keybindings = [0x9, 0xA0] maps key 0 to 0xA0 instead of key 0x9
  • keybindings = [0x1B, 0x123] maps 0x1B to 0x23 instead of 0x123

The 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_sunshine on Linux (Ubuntu 26.04, Debug) and ran --gtest_filter=UtilityFromHexTests.*:ConfigPersistenceTest.*, together with a local, uncommitted config test that applies min_threads = 0x8 and keybindings = [0x9, 0xA0, 0x1B, 0x123] through config::apply_config_for_test:

  • on master: both tests fail (from_hex<uint32_t>("8") is 0, min_threads is 0, there is no binding for 0x9, and 0x1B maps to 35)
  • with the fix: all 12 selected tests pass

I did not run the Windows or macOS builds.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.

This PR was generated by Claude Code, Claude Opus 5.5, low thinking level

Activity

3
Dev-next-gen10d ago

This PR was generated by Claude Code, Claude Opus 5.5, low thinking level