aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-12-18 14:14:54 (GMT)
committerJouni Malinen <j@w1.fi>2009-12-18 14:14:54 (GMT)
commit3b31db5199dba0b3749d92ca4fe6633694711fa8 (patch)
tree66494d74c0467a589e41232e399258bd066b4c4b
parent0e15e529eb201478954c7104ebb22edb7fb4359b (diff)
downloadhostap-3b31db5199dba0b3749d92ca4fe6633694711fa8.zip
hostap-3b31db5199dba0b3749d92ca4fe6633694711fa8.tar.gz
hostap-3b31db5199dba0b3749d92ca4fe6633694711fa8.tar.bz2
Fix netlink payload length calculation
nlmsghdr length needs to be removed from payload length. [Bug 341]
-rw-r--r--src/drivers/driver_atheros.c2
-rw-r--r--src/drivers/driver_hostap.c2
-rw-r--r--src/drivers/driver_madwifi.c2
-rw-r--r--src/drivers/driver_nl80211.c6
-rw-r--r--src/drivers/driver_ralink.c2
-rw-r--r--src/drivers/driver_wext.c6
-rw-r--r--src/drivers/priv_netlink.h3
7 files changed, 13 insertions, 10 deletions
diff --git a/src/drivers/driver_atheros.c b/src/drivers/driver_atheros.c
index 7f5f930..8603f34 100644
--- a/src/drivers/driver_atheros.c
+++ b/src/drivers/driver_atheros.c
@@ -952,7 +952,7 @@ madwifi_wireless_event_rtm_newlink(struct madwifi_driver_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
diff --git a/src/drivers/driver_hostap.c b/src/drivers/driver_hostap.c
index c781bb9..173c800 100644
--- a/src/drivers/driver_hostap.c
+++ b/src/drivers/driver_hostap.c
@@ -922,7 +922,7 @@ static void hostapd_wireless_event_rtm_newlink(struct hostap_driver_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
diff --git a/src/drivers/driver_madwifi.c b/src/drivers/driver_madwifi.c
index f1c1474..b06eaf8 100644
--- a/src/drivers/driver_madwifi.c
+++ b/src/drivers/driver_madwifi.c
@@ -1022,7 +1022,7 @@ madwifi_wireless_event_rtm_newlink(struct madwifi_driver_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 1f5e21c..0c12109 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -425,7 +425,7 @@ static int wpa_driver_nl80211_own_ifname(struct wpa_driver_nl80211_data *drv,
_nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - _nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return 0;
@@ -504,7 +504,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(struct wpa_driver_nl80211_data
_nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - _nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
@@ -538,7 +538,7 @@ static void wpa_driver_nl80211_event_rtm_dellink(struct wpa_driver_nl80211_data
_nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - _nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
diff --git a/src/drivers/driver_ralink.c b/src/drivers/driver_ralink.c
index 431d38f..e1f1391 100644
--- a/src/drivers/driver_ralink.c
+++ b/src/drivers/driver_ralink.c
@@ -764,7 +764,7 @@ wpa_driver_ralink_event_rtm_newlink(struct wpa_driver_ralink_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
wpa_printf(MSG_DEBUG, "attrlen=%d", attrlen);
if (attrlen < 0)
return;
diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
index 9d6a48d..e3652d9 100644
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -637,7 +637,7 @@ static int wpa_driver_wext_own_ifname(struct wpa_driver_wext_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return 0;
@@ -716,7 +716,7 @@ static void wpa_driver_wext_event_rtm_newlink(struct wpa_driver_wext_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
@@ -753,7 +753,7 @@ static void wpa_driver_wext_event_rtm_dellink(struct wpa_driver_wext_data *drv,
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
- attrlen = h->nlmsg_len - nlmsg_len;
+ attrlen = NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg));
if (attrlen < 0)
return;
diff --git a/src/drivers/priv_netlink.h b/src/drivers/priv_netlink.h
index 2a31e25..0ab0bb2 100644
--- a/src/drivers/priv_netlink.h
+++ b/src/drivers/priv_netlink.h
@@ -53,8 +53,11 @@
#define NLMSG_ALIGNTO 4
#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
+#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
#define NLMSG_LENGTH(len) ((len) + NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
#define NLMSG_DATA(nlh) ((void*) (((char*) nlh) + NLMSG_LENGTH(0)))
+#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
#define RTA_ALIGNTO 4
#define RTA_ALIGN(len) (((len) + RTA_ALIGNTO - 1) & ~(RTA_ALIGNTO - 1))