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

linux: Open files with O_CLOEXEC to not leak fds to child processes #446

Merged
merged 1 commit into from
Aug 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static int get_hid_report_descriptor(const char *rpt_path, struct hidraw_report_
int rpt_handle;
ssize_t res;

rpt_handle = open(rpt_path, O_RDONLY);
rpt_handle = open(rpt_path, O_RDONLY | O_CLOEXEC);
if (rpt_handle < 0) {
register_global_error_format("open failed (%s): %s", rpt_path, strerror(errno));
return -1;
Expand Down Expand Up @@ -473,7 +473,7 @@ static int parse_hid_vid_pid_from_uevent_path(const char *uevent_path, unsigned
int handle;
ssize_t res;

handle = open(uevent_path, O_RDONLY);
handle = open(uevent_path, O_RDONLY | O_CLOEXEC);
if (handle < 0) {
register_global_error_format("open failed (%s): %s", uevent_path, strerror(errno));
return 0;
Expand Down Expand Up @@ -981,7 +981,7 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)

dev = new_hid_device();

dev->device_handle = open(path, O_RDWR);
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);

/* If we have a good handle, return it. */
if (dev->device_handle >= 0) {
Expand Down