summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/iwinfo/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-10-03 18:32:29 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-10-03 18:32:29 +0000
commit2c9b1c4a1b74271fd149ea0035cec1acf9754966 (patch)
tree005885bd00de1edefd2d9ae89beeb74694b099c3 /contrib/package/iwinfo/src
parente3570b7b0d04205b53f45c8e6ad29379fb2674db (diff)
[libiwinfo] apply FD_CLOEXEC on internal ioctl and netlink sockets
Diffstat (limited to 'contrib/package/iwinfo/src')
-rw-r--r--contrib/package/iwinfo/src/iwinfo_madwifi.c3
-rw-r--r--contrib/package/iwinfo/src/iwinfo_madwifi.h2
-rw-r--r--contrib/package/iwinfo/src/iwinfo_nl80211.c12
-rw-r--r--contrib/package/iwinfo/src/iwinfo_nl80211.h1
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wext.c3
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wext.h2
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wext_scan.c8
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wext_scan.h6
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wl.c3
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wl.h2
10 files changed, 36 insertions, 6 deletions
diff --git a/contrib/package/iwinfo/src/iwinfo_madwifi.c b/contrib/package/iwinfo/src/iwinfo_madwifi.c
index 9b761edfa..daecf5df3 100644
--- a/contrib/package/iwinfo/src/iwinfo_madwifi.c
+++ b/contrib/package/iwinfo/src/iwinfo_madwifi.c
@@ -202,7 +202,10 @@ static int madwifi_ioctl(struct iwreq *wrq, const char *ifname, int cmd, void *d
{
/* prepare socket */
if( ioctl_socket == -1 )
+ {
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
+ fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
+ }
strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
diff --git a/contrib/package/iwinfo/src/iwinfo_madwifi.h b/contrib/package/iwinfo/src/iwinfo_madwifi.h
index 9f9ffe5d8..1f2291838 100644
--- a/contrib/package/iwinfo/src/iwinfo_madwifi.h
+++ b/contrib/package/iwinfo/src/iwinfo_madwifi.h
@@ -19,6 +19,8 @@
#ifndef __IWINFO_MADWIFI_H_
#define __IWINFO_MADWIFI_H_
+#include <fcntl.h>
+
#include "iwinfo.h"
#include "include/madwifi.h"
diff --git a/contrib/package/iwinfo/src/iwinfo_nl80211.c b/contrib/package/iwinfo/src/iwinfo_nl80211.c
index a643efbdc..49ddf13fb 100644
--- a/contrib/package/iwinfo/src/iwinfo_nl80211.c
+++ b/contrib/package/iwinfo/src/iwinfo_nl80211.c
@@ -32,7 +32,7 @@ static struct nl80211_state *nls = NULL;
static int nl80211_init(void)
{
- int err;
+ int err, fd;
if( !nls )
{
@@ -53,6 +53,13 @@ static int nl80211_init(void)
goto err;
}
+ fd = nl_socket_get_fd(nls->nl_sock);
+ if( fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) < 0 )
+ {
+ err = -EINVAL;
+ goto err;
+ }
+
if( genl_ctrl_alloc_cache(nls->nl_sock, &nls->nl_cache)) {
err = -ENOMEM;
goto err;
@@ -332,6 +339,9 @@ static char * nl80211_wpasupp_info(const char *ifname, const char *cmd)
remote_length = sizeof(remote.sun_family) + sprintf(remote.sun_path,
"/var/run/wpa_supplicant-%s/%s", ifname, ifname);
+ if( fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC) < 0 )
+ goto out;
+
if( connect(sock, (struct sockaddr *) &remote, remote_length) )
goto out;
diff --git a/contrib/package/iwinfo/src/iwinfo_nl80211.h b/contrib/package/iwinfo/src/iwinfo_nl80211.h
index dd38b960f..0cf74195d 100644
--- a/contrib/package/iwinfo/src/iwinfo_nl80211.h
+++ b/contrib/package/iwinfo/src/iwinfo_nl80211.h
@@ -20,6 +20,7 @@
#define __IWINFO_NL80211_H_
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
diff --git a/contrib/package/iwinfo/src/iwinfo_wext.c b/contrib/package/iwinfo/src/iwinfo_wext.c
index 8fe0305f1..7bd1574c1 100644
--- a/contrib/package/iwinfo/src/iwinfo_wext.c
+++ b/contrib/package/iwinfo/src/iwinfo_wext.c
@@ -89,7 +89,10 @@ static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
{
/* prepare socket */
if( ioctl_socket == -1 )
+ {
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
+ fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
+ }
if( !strncmp(ifname, "mon.", 4) )
strncpy(wrq->ifr_name, &ifname[4], IFNAMSIZ);
diff --git a/contrib/package/iwinfo/src/iwinfo_wext.h b/contrib/package/iwinfo/src/iwinfo_wext.h
index eb2df4f0f..917ea121f 100644
--- a/contrib/package/iwinfo/src/iwinfo_wext.h
+++ b/contrib/package/iwinfo/src/iwinfo_wext.h
@@ -19,6 +19,8 @@
#ifndef __IWINFO_WEXT_H_
#define __IWINFO_WEXT_H_
+#include <fcntl.h>
+
#include "iwinfo.h"
#include "include/wext.h"
diff --git a/contrib/package/iwinfo/src/iwinfo_wext_scan.c b/contrib/package/iwinfo/src/iwinfo_wext_scan.c
index b0c1f15e8..f81261837 100644
--- a/contrib/package/iwinfo/src/iwinfo_wext_scan.c
+++ b/contrib/package/iwinfo/src/iwinfo_wext_scan.c
@@ -29,7 +29,10 @@ static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
{
/* prepare socket */
if( ioctl_socket == -1 )
+ {
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
+ fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
+ }
strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
return ioctl(ioctl_socket, cmd, wrq);
@@ -249,7 +252,7 @@ static inline void wext_fill_wpa(unsigned char *iebuf, int buflen, struct iwinfo
case 0xdd: /* WPA or else */
wpa_oui = wpa1_oui;
- /* Not all IEs that start with 0xdd are WPA.
+ /* Not all IEs that start with 0xdd are WPA.
* * So check that the OUI is valid. */
if((ielen < 8) || ((memcmp(&iebuf[offset], wpa_oui, 3) != 0)
&& (iebuf[offset+3] == 0x01)))
@@ -477,7 +480,7 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len)
wrq.u.data.pointer = (caddr_t) &range;
wrq.u.data.length = sizeof(struct iw_range);
- wrq.u.data.flags = 0;
+ wrq.u.data.flags = 0;
if( wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0 )
{
@@ -650,4 +653,3 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len)
return -1;
}
-
diff --git a/contrib/package/iwinfo/src/iwinfo_wext_scan.h b/contrib/package/iwinfo/src/iwinfo_wext_scan.h
index 2c709a11b..6456c28ff 100644
--- a/contrib/package/iwinfo/src/iwinfo_wext_scan.h
+++ b/contrib/package/iwinfo/src/iwinfo_wext_scan.h
@@ -19,6 +19,8 @@
#ifndef __IWINFO_WEXT_SCAN_H_
#define __IWINFO_WEXT_SCAN_H_
+#include <fcntl.h>
+
#include "iwinfo.h"
#include "include/wext.h"
@@ -320,7 +322,7 @@ static const struct iw_ioctl_description standard_event_descr[] = {
.header_type = IW_HEADER_TYPE_ADDR,
},
[IWEVEXPIRED - IWEVFIRST] = {
- .header_type = IW_HEADER_TYPE_ADDR,
+ .header_type = IW_HEADER_TYPE_ADDR,
},
[IWEVGENIE - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
@@ -328,7 +330,7 @@ static const struct iw_ioctl_description standard_event_descr[] = {
.max_tokens = IW_GENERIC_IE_MAX,
},
[IWEVMICHAELMICFAILURE - IWEVFIRST] = {
- .header_type = IW_HEADER_TYPE_POINT,
+ .header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = sizeof(struct iw_michaelmicfailure),
},
diff --git a/contrib/package/iwinfo/src/iwinfo_wl.c b/contrib/package/iwinfo/src/iwinfo_wl.c
index 2dac12b1a..81df81faf 100644
--- a/contrib/package/iwinfo/src/iwinfo_wl.c
+++ b/contrib/package/iwinfo/src/iwinfo_wl.c
@@ -30,7 +30,10 @@ static int wl_ioctl(const char *name, int cmd, void *buf, int len)
/* prepare socket */
if( ioctl_socket == -1 )
+ {
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
+ fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
+ }
/* do it */
ioc.cmd = cmd;
diff --git a/contrib/package/iwinfo/src/iwinfo_wl.h b/contrib/package/iwinfo/src/iwinfo_wl.h
index f22f1f317..0a991a35f 100644
--- a/contrib/package/iwinfo/src/iwinfo_wl.h
+++ b/contrib/package/iwinfo/src/iwinfo_wl.h
@@ -19,6 +19,8 @@
#ifndef __IWINFO_WL_H_
#define __IWINFO_WL_H_
+#include <fcntl.h>
+
#include "iwinfo.h"
#include "include/broadcom.h"