Merge pull request #10732 from yuwata/network-sock_cloexec
dhcp, fuzz: set SOCK_CLOEXEC and SOCK_NONBLOCK
This commit is contained in:
commit
707ade9d13
|
@ -10,7 +10,7 @@
|
|||
#include "fd-util.h"
|
||||
#include "fuzz.h"
|
||||
|
||||
static int test_dhcp_fd[2];
|
||||
static int test_dhcp_fd[2] = { -1, -1 };
|
||||
|
||||
int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
|
||||
const void *packet, size_t len) {
|
||||
|
@ -18,7 +18,7 @@ int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
|
|||
}
|
||||
|
||||
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
|
||||
assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, test_dhcp_fd) >= 0);
|
||||
assert_se(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_dhcp_fd) >= 0);
|
||||
return test_dhcp_fd[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
static int test_fd[2] = { -1, -1 };
|
||||
|
||||
int lldp_network_bind_raw_socket(int ifindex) {
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return test_fd[0];
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "socket-util.h"
|
||||
#include "ndisc-internal.h"
|
||||
|
||||
static int test_fd[2];
|
||||
static int test_fd[2] = { -1, -1 };
|
||||
|
||||
int icmp6_bind_router_solicitation(int index) {
|
||||
assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, test_fd) >= 0);
|
||||
assert_se(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0);
|
||||
return test_fd[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -988,7 +988,7 @@ int sd_dhcp_server_start(sd_dhcp_server *server) {
|
|||
assert_return(server->fd < 0, -EBUSY);
|
||||
assert_return(server->address != htobe32(INADDR_ANY), -EUNATCH);
|
||||
|
||||
r = socket(AF_PACKET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
||||
r = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
|
||||
if (r < 0) {
|
||||
r = -errno;
|
||||
sd_dhcp_server_stop(server);
|
||||
|
|
|
@ -232,7 +232,7 @@ int dhcp_network_bind_raw_socket(
|
|||
const uint8_t *addr, size_t addr_len,
|
||||
uint16_t arp_type, uint16_t port) {
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, test_fd) < 0)
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return test_fd[0];
|
||||
|
@ -241,7 +241,7 @@ int dhcp_network_bind_raw_socket(
|
|||
int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) {
|
||||
int fd;
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
|
|
|
@ -878,7 +878,7 @@ int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
|
|||
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
|
||||
assert_se(index == test_index);
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, test_dhcp_fd) < 0)
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_dhcp_fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return test_dhcp_fd[0];
|
||||
|
|
|
@ -79,7 +79,7 @@ int arp_send_announcement(int fd, int ifindex,
|
|||
}
|
||||
|
||||
int arp_network_bind_raw_socket(int index, be32_t address, const struct ether_addr *eth_mac) {
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return test_fd[0];
|
||||
|
|
|
@ -24,7 +24,7 @@ static int test_fd[2] = { -1, -1 };
|
|||
static int lldp_handler_calls;
|
||||
|
||||
int lldp_network_bind_raw_socket(int ifindex) {
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return test_fd[0];
|
||||
|
|
|
@ -297,7 +297,7 @@ static void test_ra(void) {
|
|||
|
||||
printf("* %s\n", __FUNCTION__);
|
||||
|
||||
assert_se(socketpair(AF_UNIX, SOCK_SEQPACKET, 0, test_fd) >= 0);
|
||||
assert_se(socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0);
|
||||
|
||||
assert_se(sd_event_new(&e) >= 0);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ static int test_rs_hangcheck(sd_event_source *s, uint64_t usec,
|
|||
int icmp6_bind_router_solicitation(int index) {
|
||||
assert_se(index == 42);
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, test_fd) < 0)
|
||||
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return test_fd[0];
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue