Skip to content

Commit

Permalink
libnetutils/packet.c - create socket with close-on-exec
Browse files Browse the repository at this point in the history
This prevents fork/exec leaking sockets to child processes.

Test: builds, atest
Bug: 155297277
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I57cb2003dd75b0bc5528978fd131730273e37a43
Merged-In: I57cb2003dd75b0bc5528978fd131730273e37a43

Former-commit-id: ecfb05d4ce67b19e087d3d5fb1a932ec7e71ceb3
  • Loading branch information
zenczykowski committed May 11, 2020
1 parent ee7c41a commit cf1508a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libnetutils/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
int fatal(const char*);

int open_raw_socket(const char* ifname __unused, uint8_t hwaddr[ETH_ALEN], int if_index) {
int s = socket(PF_PACKET, SOCK_DGRAM, 0);
int s = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (s < 0) return fatal("socket(PF_PACKET)");

struct sockaddr_ll bindaddr = {
Expand Down

0 comments on commit cf1508a

Please sign in to comment.