Skip to content

Conversation

forderud
Copy link
Contributor

@forderud forderud commented Oct 14, 2024

See #29 for an alternative proposal.

The method currently uses a local bval variable as argument when calling HID().SendReport(...). This is problematic, since the SendReport method doesn't use bval immediately. It instead captures a pointer to bval which is accessed when the report is sent at a later point. This leads to a use-after-free situation when the pointer captured by SendReport no longer point to bval, but some other unknown data.

Propose to fix the issue by introducing a new iManufacturerDate member in the HIDPowerDevice class to act as persistent storage for the date value.

Also, change HIDPowerDevice_::sendDate to send the date as a FEATURE report instead of a INPUT report, so that it matches the ManufacturerDate parameter in the HID descriptor. This is also required in order for the date to be picked up on Windows.

@forderud
Copy link
Contributor Author

forderud commented Jan 11, 2025

@abratchik Would it be possible for you to take a look at either this PR or #29?

I've already tested the change locally.

The method currently uses a local "bval" variable as argument when calling HID().SendReport(...). This is problematic, since the SendReport method doesn't use "bval" immediately. It instead captures a pointer to "bval" which is accessed when the report is sent at a later point. This leads to a use-after-free situation when the pointer captured by SendReport may no longer point to "bval".

Propose to fix the issue by introducing a new "iManufacturerDate" member in the HIDPowerDevice class to act as persistent storage for the date value.
… instead of a INPUT report, so that it matches the ManufacturerDate parameter in the HID descriptor. This is also required in order for the date to be picked up on Windows.
…nt8_t month, uint8_t day)" since it's anyhow tied to the ManufacturerDate parameter.
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.

1 participant