3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-05 03:29:24 +01:00

nl80211util: Ensure all entries are parsed

The current logic did not make sure that each entry provided was
actually parsed.  Also add a sanity check to make sure that no duplicate
parsing occurs.
This commit is contained in:
Denis Kenzior 2019-10-25 13:46:58 -05:00
parent d577036879
commit 3b937424db

View File

@ -110,6 +110,7 @@ struct attr_entry {
uint16_t type; uint16_t type;
void *data; void *data;
attr_handler handler; attr_handler handler;
bool present : 1;
}; };
int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...) int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...)
@ -158,10 +159,28 @@ int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...)
if (!e) if (!e)
continue; continue;
if (entry->present) {
ret = -EALREADY;
goto done;
}
if (!entry->handler(data, len, entry->data)) { if (!entry->handler(data, len, entry->data)) {
ret = -EINVAL; ret = -EINVAL;
goto done; goto done;
} }
entry->present = true;
}
ret = -ENOENT;
for (e = l_queue_get_entries(entries); e; e = e->next) {
entry = e->data;
if (entry->present)
continue;
goto done;
} }
ret = 0; ret = 0;