Skip to content

Commit

Permalink
qrexec-daemon: Use close_range where possible
Browse files Browse the repository at this point in the history
This makes things faster and trivially more correct.
  • Loading branch information
DemiMarie committed May 16, 2024
1 parent 43f49f0 commit 49f9710
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions daemon/qrexec-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
Expand Down Expand Up @@ -1122,8 +1123,14 @@ _Noreturn static void handle_execute_service_child(
const struct service_params *request_id) {
int i;

for (i = 3; i < MAX_FDS; i++)
close(i);
#ifdef SYS_close_range
int close_range_res = syscall(SYS_close_range, 3, ~0U, 0);
#else
int close_range_res = -1;
#endif
if (close_range_res != 0)
for (i = 3; i < MAX_FDS; i++)
close(i);

Check warning on line 1133 in daemon/qrexec-daemon.c

View check run for this annotation

Codecov / codecov/patch

daemon/qrexec-daemon.c#L1132-L1133

Added lines #L1132 - L1133 were not covered by tests

char *user, *target, *requested_target;
int autostart;
Expand Down

0 comments on commit 49f9710

Please sign in to comment.