Skip to content

fix(windows): prevent VHF report buffer overruns - #200

Open
ReenigneArcher wants to merge 1 commit into
masterfrom
codex/fix-windows-vhf-report-overrun
Open

ReenigneArcher wants to merge 1 commit into
masterfrom
codex/fix-windows-vhf-report-overrun

Conversation

@ReenigneArcher

Copy link
Copy Markdown
Member

Description

On affected Windows 10 systems, a DualSense pairing GetFeature callback advertises 128 bytes for a 64-byte VHF buffer. Clearing the advertised length overwrites the allocation and crashes WUDFHost; the PageHeap dump in #199 catches that write directly.

Use a shared response copier in GetFeature and GetInputReport that writes only the actual report bytes. Preserve undersized-request rejection and the optional zero ID for unnumbered input reports.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

  • Added five regression tests covering oversized feature/input requests, optional zero IDs, short requests, and exact-size requests. Three fail with the original clearing behavior; all five pass with the fix.
  • MSYS2/UCRT64: built test_libvirtualhid and gamepad_adapter; 47 focused protocol, backend, lifecycle, adapter, and native HID/SDL tests passed.
  • MSVC/WDK: cmake --build cmake-build-issue199-msvc-driver --config Release --target libvirtualhid_umdf -j 4 passed.
  • clang-format --dry-run --Werror on the three changed files and git diff --check passed.
  • Installed-device smoke tests used the existing Windows 11 driver. The newly built driver still needs a signed build and a PageHeap retest on the affected Windows 10 system.

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

Generated with Codex (model: gpt-6.1-sol; thinking level: xhigh).

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.71%. Comparing base (1aea6e3) to head (7486821).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #200    +/-   ##
========================================
  Coverage   73.71%   73.71%            
========================================
  Files          43       44     +1     
  Lines       10670    10680    +10     
  Branches     3677     3681     +4     
========================================
+ Hits         7865     7873     +8     
+ Misses       2445     2183   -262     
- Partials      360      624   +264     
Flag Coverage Δ
FreeBSD 53.99% <ø> (ø)
Linux-Clang 68.69% <ø> (-0.04%) ⬇️
Linux-GCC 80.92% <ø> (ø)
PowerShell 75.60% <ø> (ø)
Windows-MSVC 74.03% <100.00%> (-0.14%) ⬇️
Windows-MinGW-UCRT64 66.22% <100.00%> (+0.11%) ⬆️
macOS 50.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rc/platform/windows/shared/vhf_report_response.hpp 100.00% <100.00%> (ø)

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1aea6e3...7486821. Read the comment docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant