Skip to content
New issue

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

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

Already on GitHub? # to your account

hidapi/linux: fix uninitialized variable #692

Closed
wants to merge 1 commit into from

Conversation

0xilis
Copy link

@0xilis 0xilis commented Sep 15, 2024

In parse_hid_vid_pid_from_uevent_path, if the file is less than 1024 bytes somehow, the read() call will return the size of the file and pass the if (res < 0) check, but the leftover bytes that were not copied to from the file will remain uninitialized. This commit fixed it by initializing the buffer with 0.

@mcuee mcuee added the hidraw Related to Linux/hidraw backend label Sep 15, 2024
@Youw
Copy link
Member

Youw commented Sep 15, 2024

  1. I can't even recall it C supports = {0} initialisation by the standard.

  2. The function ensures that the string is NULL-terminated and that buffer is always threated as a c-string, so uninitialized part of the memory would never be read. Unless you've found a an excemple where it actually fails. Did you?

@Youw
Copy link
Member

Youw commented Sep 29, 2024

I don't see reasons having this accepted and no response from author.

@Youw Youw closed this Sep 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
hidraw Related to Linux/hidraw backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants