Message ID | CAFA2y8XTa=Dv=vz-r7P4zx3RbdEwM2Tbhq2K=65gruG9UXQHAw@mail.gmail.com |
---|---|
State | Accepted |
Headers | show |
On Tue, Jan 28, 2014 at 11:14:57AM +0530, shital jaju wrote: > This checks if attribute ifidx is present, > before trying to get the value of interface index. > diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c > @@ -10552,7 +10552,10 @@ static int survey_handler(struct nl_msg *msg, void > *arg) > - ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); > + if (tb[NL80211_ATTR_IFINDEX]) > + ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); > + else > + return NL_SKIP; > if (!tb[NL80211_ATTR_SURVEY_INFO]) > return NL_SKIP; While this would obviously do no harm and would be safe to apply, I would like to understand why this would be needed. Is there a kernel version somewhere that does not include NL80211_ATTR_IFINDEX in the survey data? As far as I can see, cfg80211 adds it unconditionally to all survey results. I think I'll apply this anyway since driver_nl80211.c tries to follow the policy of validating all messages from the kernel.
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index b5bf368..1d3c663 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -10552,7 +10552,10 @@ static int survey_handler(struct nl_msg *msg, void *arg) nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); - ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); + if (tb[NL80211_ATTR_IFINDEX]) + ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); + else + return NL_SKIP; if (!tb[NL80211_ATTR_SURVEY_INFO])