Page MenuHomeFreeBSD

hidraw: Return string lengths for certain ioctls
ClosedPublic

Authored by grembo on May 17 2022, 9:43 AM.
Tags
None
Referenced Files
F108308916: D35233.id106096.diff
Thu, Jan 23, 6:27 PM
Unknown Object (File)
Tue, Jan 21, 4:13 PM
Unknown Object (File)
Dec 23 2024, 10:12 AM
Unknown Object (File)
Dec 21 2024, 8:28 AM
Unknown Object (File)
Dec 10 2024, 8:06 AM
Unknown Object (File)
Dec 6 2024, 12:59 PM
Unknown Object (File)
Dec 5 2024, 7:09 AM
Unknown Object (File)
Nov 25 2024, 3:25 AM
Subscribers

Details

Summary

The hidraw(4) driver provides a set of Linux compatible ioctls. Three
of these return the length of the copied string on Linux, but they
always return 0 on FreeBSD:

  • HIDIOCGRAWPHYS
  • HIDIOCGRAWNAME
  • HIDIOCGRAWUNIQ

I noticed this while implementing hidraw(4) support for FreeBSD in
python-fido2[0], so there is some real-world software relying on
this return value (I would assume that this isn't the only one).

This patch aims to fix this by returning the length of the copied
string (including the trailing NUL character) in the affected ioctls.

[0]
https://github.com/Yubico/python-fido2/pull/139
https://github.com/Yubico/python-fido2/blob/master/fido2/hid/linux.py#L63-L74

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 45605
Build 42493: arc lint + arc unit

Event Timeline

grembo edited the summary of this revision. (Show Details)
  • Make strlen calculation behave like on Linux (count trailing NUL)
This revision is now accepted and ready to land.May 17 2022, 9:29 PM