Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VID, PID and Subdev comparison cause unintended sign extension #76

Open
f14h opened this issue Nov 13, 2024 · 0 comments
Open

VID, PID and Subdev comparison cause unintended sign extension #76

f14h opened this issue Nov 13, 2024 · 0 comments

Comments

@f14h
Copy link

f14h commented Nov 13, 2024

VID, PID and SUBDEV are all unsigned 16bit values (per PCI specification).

As the corresponding struct uses signed 16bit values (on most architectures, implemented as short) and the bdx_get_phy_by_id function uses signed ints (32bit on most architectures) as arguments. This will cause an unintended sign extension e.g. for the "Edimax 10 Gigabit Ethernet SFP+ PCI Express Adapter" which has a subdev ID of 0x8103 (which will get extended to 0xffff8103) thus failing the comparison.

Fixing the struct to use ints instead was successful in our quick and dirty test, however, using u16 everywhere might be cleaner.

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

No branches or pull requests

1 participant