summaryrefslogtreecommitdiff
path: root/gdhcp
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-10-23 14:16:26 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-10-25 13:35:14 +0200
commitd997ab9aa2dab15d486b3836e5dc04ae23fefdc0 (patch)
treeb28d41072f61c7e756db5b783ac32a03ff8cbaad /gdhcp
parentc94b607044db60e5ff6a4b0a861a90bee35b3bc0 (diff)
downloadconnman-d997ab9aa2dab15d486b3836e5dc04ae23fefdc0.tar.gz
connman-d997ab9aa2dab15d486b3836e5dc04ae23fefdc0.tar.bz2
connman-d997ab9aa2dab15d486b3836e5dc04ae23fefdc0.zip
gdhcp: Add SOCK_CLOEXEC to socket()
Make sure all file descriptor are closed.
Diffstat (limited to 'gdhcp')
-rw-r--r--gdhcp/client.c4
-rw-r--r--gdhcp/common.c10
-rw-r--r--gdhcp/ipv4ll.c4
-rw-r--r--gdhcp/server.c2
4 files changed, 10 insertions, 10 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 8ea75d65..24614c76 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -361,7 +361,7 @@ static void get_interface_mac_address(int index, uint8_t *mac_address)
struct ifreq ifr;
int sk, err;
- sk = socket(PF_INET, SOCK_DGRAM, 0);
+ sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sk < 0) {
perror("Open socket error");
return;
@@ -515,7 +515,7 @@ static int dhcp_l2_socket(int ifindex)
.filter = (struct sock_filter *) filter_instr,
};
- fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
+ fd = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IP));
if (fd < 0)
return fd;
diff --git a/gdhcp/common.c b/gdhcp/common.c
index ff25dfe8..43f67355 100644
--- a/gdhcp/common.c
+++ b/gdhcp/common.c
@@ -301,7 +301,7 @@ int dhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
offsetof(struct ip_udp_dhcp_packet, udp),
};
- fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
+ fd = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IP));
if (fd < 0)
return -errno;
@@ -363,7 +363,7 @@ int dhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
EXTEND_FOR_BUGGY_SERVERS,
};
- fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
if (fd < 0)
return -errno;
@@ -402,7 +402,7 @@ int dhcp_l3_socket(int port, const char *interface)
int fd, opt = 1;
struct sockaddr_in addr;
- fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
@@ -431,7 +431,7 @@ char *get_interface_name(int index)
if (index < 0)
return NULL;
- sk = socket(PF_INET, SOCK_DGRAM, 0);
+ sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sk < 0) {
perror("Open socket error");
return NULL;
@@ -458,7 +458,7 @@ gboolean interface_is_up(int index)
struct ifreq ifr;
gboolean ret = FALSE;
- sk = socket(PF_INET, SOCK_DGRAM, 0);
+ sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sk < 0) {
perror("Open socket error");
return FALSE;
diff --git a/gdhcp/ipv4ll.c b/gdhcp/ipv4ll.c
index b35626d1..4c095722 100644
--- a/gdhcp/ipv4ll.c
+++ b/gdhcp/ipv4ll.c
@@ -79,7 +79,7 @@ int ipv4ll_send_arp_packet(uint8_t* source_eth, uint32_t source_ip,
uint32_t ip_target;
int fd, n;
- fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ARP));
+ fd = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_ARP));
if (fd < 0)
return -errno;
@@ -122,7 +122,7 @@ int ipv4ll_arp_socket(int ifindex)
{
int fd;
struct sockaddr_ll sock;
- fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ARP));
+ fd = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_ARP));
if (fd < 0)
return fd;
diff --git a/gdhcp/server.c b/gdhcp/server.c
index 099c50cc..54c068b7 100644
--- a/gdhcp/server.c
+++ b/gdhcp/server.c
@@ -317,7 +317,7 @@ static uint32_t get_interface_address(int index)
struct sockaddr_in *server_ip;
uint32_t ret = 0;
- sk = socket(PF_INET, SOCK_DGRAM, 0);
+ sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sk < 0) {
perror("Open socket error");
return 0;