Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net80211 Style, and zero out 'ns' entirely, otherwise so...
details: https://anonhg.NetBSD.org/src/rev/9c73ae5b0f1c
branches: trunk
changeset: 358832:9c73ae5b0f1c
user: maxv <maxv%NetBSD.org@localhost>
date: Thu Jan 18 17:57:49 2018 +0000
description:
Style, and zero out 'ns' entirely, otherwise some bytes get leaked to
userland (eg ns_rsvd0).
diffstat:
sys/net80211/ieee80211_netbsd.c | 59 +++++++++++++++++++++++-----------------
1 files changed, 34 insertions(+), 25 deletions(-)
diffs (202 lines):
diff -r 3935b3c4cbcd -r 9c73ae5b0f1c sys/net80211/ieee80211_netbsd.c
--- a/sys/net80211/ieee80211_netbsd.c Thu Jan 18 16:23:43 2018 +0000
+++ b/sys/net80211/ieee80211_netbsd.c Thu Jan 18 17:57:49 2018 +0000
@@ -1,5 +1,6 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.29 2017/01/14 16:34:44 maya Exp $ */
-/*-
+/* $NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $ */
+
+/*
* Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
* All rights reserved.
*
@@ -30,7 +31,7 @@
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
#else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.29 2017/01/14 16:34:44 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $");
#endif
/*
@@ -38,8 +39,8 @@
*/
#include <sys/param.h>
#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/once.h>
@@ -89,7 +90,7 @@
max_linkhdr = ALIGN(sizeof(struct ieee80211_qosframe_addr4));
}
- __link_set_foreach(ieee80211_setup, ieee80211_funcs) {
+ __link_set_foreach(ieee80211_setup, ieee80211_funcs) {
f = (void*)*ieee80211_setup;
(*f)();
}
@@ -112,22 +113,25 @@
struct sysctlnode node;
node = *rnode;
- /* sysctl_lookup copies the product from t. Then, it
+
+ /*
+ * sysctl_lookup copies the product from t. Then, it
* copies the new value onto t.
*/
t = *(int*)rnode->sysctl_data * IEEE80211_INACT_WAIT;
node.sysctl_data = &t;
error = sysctl_lookup(SYSCTLFN_CALL(&node));
if (error || newp == NULL)
- return (error);
+ return error;
- /* The new value was in seconds. Convert to inactivity-wait
+ /*
+ * The new value was in seconds. Convert to inactivity-wait
* intervals. There are IEEE80211_INACT_WAIT seconds per
* interval.
*/
*(int*)rnode->sysctl_data = t / IEEE80211_INACT_WAIT;
- return (0);
+ return 0;
}
static int
@@ -263,11 +267,11 @@
*
* If there is any single 802.11 interface, ieee80211_node_walkfirst
* must not return NULL.
- */
+ */
static struct ieee80211_node *
ieee80211_node_walkfirst(struct ieee80211_node_walk *nw, u_short if_index)
{
- (void)memset(nw, 0, sizeof(*nw));
+ memset(nw, 0, sizeof(*nw));
nw->nw_ifindex = if_index;
@@ -332,11 +336,13 @@
struct ieee80211_node_sysctl *ns, int ifindex,
const struct ieee80211_channel *chan0, uint32_t flags)
{
+ memset(ns, 0, sizeof(*ns));
+
ns->ns_ifindex = ifindex;
ns->ns_capinfo = ni->ni_capinfo;
ns->ns_flags = flags;
- (void)memcpy(ns->ns_macaddr, ni->ni_macaddr, sizeof(ns->ns_macaddr));
- (void)memcpy(ns->ns_bssid, ni->ni_bssid, sizeof(ns->ns_bssid));
+ memcpy(ns->ns_macaddr, ni->ni_macaddr, sizeof(ns->ns_macaddr));
+ memcpy(ns->ns_bssid, ni->ni_bssid, sizeof(ns->ns_bssid));
if (ni->ni_chan != IEEE80211_CHAN_ANYC) {
ns->ns_freq = ni->ni_chan->ic_freq;
ns->ns_chanflags = ni->ni_chan->ic_flags;
@@ -347,7 +353,7 @@
}
ns->ns_rssi = ni->ni_rssi;
ns->ns_esslen = ni->ni_esslen;
- (void)memcpy(ns->ns_essid, ni->ni_essid, sizeof(ns->ns_essid));
+ memcpy(ns->ns_essid, ni->ni_essid, sizeof(ns->ns_essid));
ns->ns_erp = ni->ni_erp;
ns->ns_associd = ni->ni_associd;
ns->ns_inact = ni->ni_inact * IEEE80211_INACT_WAIT;
@@ -355,7 +361,7 @@
ns->ns_rates = ni->ni_rates;
ns->ns_txrate = ni->ni_txrate;
ns->ns_intval = ni->ni_intval;
- (void)memcpy(ns->ns_tstamp, &ni->ni_tstamp, sizeof(ns->ns_tstamp));
+ memcpy(ns->ns_tstamp, &ni->ni_tstamp, sizeof(ns->ns_tstamp));
ns->ns_txseq = ni->ni_txseqs[0];
ns->ns_rxseq = ni->ni_rxseqs[0];
ns->ns_fhdwell = ni->ni_fhdwell;
@@ -485,7 +491,7 @@
"debug", SYSCTL_DESCR("control debugging printfs"),
NULL, 0, &ieee80211_debug, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
-#endif /* IEEE80211_DEBUG */
+#endif
ieee80211_rssadapt_sysctl_setup(&ieee80211_sysctllog);
@@ -524,7 +530,6 @@
}
}
-
void
if_printf(struct ifnet *ifp, const char *fmt, ...)
{
@@ -538,7 +543,6 @@
return;
}
-
/*
* Allocate and setup a management frame of the specified
* size. We return the mbuf and a pointer to the start
@@ -561,6 +565,7 @@
/* XXX 4-address frame? */
len = roundup(sizeof(struct ieee80211_frame) + pktlen, 4);
IASSERT(len <= MCLBYTES, ("802.11 mgt frame too large: %u", len));
+
if (len <= MHLEN) {
m = m_gethdr(M_NOWAIT, MT_HEADER);
/*
@@ -571,13 +576,16 @@
*/
if (m != NULL)
MH_ALIGN(m, len);
- } else
+ } else {
m = m_getcl(M_NOWAIT, MT_HEADER, M_PKTHDR);
+ }
+
if (m != NULL) {
m->m_data += sizeof(struct ieee80211_frame);
*frm = m->m_data;
IASSERT((uintptr_t)*frm % 4 == 0, ("bad beacon boundary"));
}
+
return m;
}
@@ -588,7 +596,8 @@
}
void
-ieee80211_notify_node_join(struct ieee80211com *ic, struct ieee80211_node *ni, int newassoc)
+ieee80211_notify_node_join(struct ieee80211com *ic, struct ieee80211_node *ni,
+ int newassoc)
{
struct ifnet *ifp = ic->ic_ifp;
struct ieee80211_join_event iev;
@@ -601,8 +610,8 @@
if (ni == ic->ic_bss) {
IEEE80211_ADDR_COPY(iev.iev_addr, ni->ni_bssid);
rt_ieee80211msg(ifp, newassoc ?
- RTM_IEEE80211_ASSOC : RTM_IEEE80211_REASSOC,
- &iev, sizeof(iev));
+ RTM_IEEE80211_ASSOC : RTM_IEEE80211_REASSOC,
+ &iev, sizeof(iev));
if_link_state_change(ifp, LINK_STATE_UP);
} else {
IEEE80211_ADDR_COPY(iev.iev_addr, ni->ni_macaddr);
@@ -681,8 +690,8 @@
struct ifnet *ifp = ic->ic_ifp;
IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
- "[%s] michael MIC verification failed <keyix %u>\n",
- ether_sprintf(wh->i_addr2), keyix);
+ "[%s] michael MIC verification failed <keyix %u>\n",
+ ether_sprintf(wh->i_addr2), keyix);
ic->ic_stats.is_rx_tkipmic++;
if (ifp != NULL) { /* NB: for cipher test modules */
Home |
Main Index |
Thread Index |
Old Index