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

Chatgpt3 #65

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Chatgpt3 #65

wants to merge 11 commits into from

Conversation

adrelanos
Copy link
Contributor

Changes for the dev branch as suggested by chatgpt AI.

Could you please check if any or even all of these changes are sensible?

Untested.

Also

        named_inputs[device_count][BUFSIZE-1] = '\0';

vs

        rescue_keys_str[BUFSIZE-1] = '\0';

seems to have a different syntax and might make assumptions about a one-dimensional array versus a two-dimensional array.

Replaced the unsafe sprintf function with the safer snprintf in the detect_devices function to avoid potential buffer overflows. The snprintf function limits the number of characters written to the size of the buffer, ensuring that buffer overflow is avoided.

Additionally, ensured that strings copied with strncpy are null-terminated, preventing issues with non-terminated strings.

This change improves the robustness and security of the code by preventing potential buffer overflows and ensuring proper string termination.
Implemented error checking for the nanosleep, ioctl, and close system calls throughout the codebase to ensure robustness and reliability. In cases where these system calls return an error, the program will now invoke the panic function, outputting the corresponding error message and terminating execution. This addition will aid in quickly identifying and resolving issues related to system call failures, thereby enhancing the stability of the software.

Modified Functions:
- sleep_ms: Added error checking for nanosleep.
- supports_event_type, supports_specific_key, init_inputs: Added error checking for ioctl.
- detect_devices: Added error checking for close.
@adrelanos
Copy link
Contributor Author

Any chance to review these smaller PRs please?

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.

None yet

1 participant