dect
/
libnl
Archived
13
0
Fork 0

attr: Warn application if nla_parse() observes same attribute multiple times

Use a debugging message to warn applications if an attribute is
found multiple times in the same message. It is perfectly valid
to rely on this behaviour but it is likely to indicate a bug.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
Thomas Graf 2013-03-13 17:12:03 +01:00
parent 64315f731c
commit 1395c69901
1 changed files with 12 additions and 7 deletions

View File

@ -254,15 +254,20 @@ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
if (type == 0)
continue;
if (type <= maxtype) {
if (policy) {
err = validate_nla(nla, maxtype, policy);
if (err < 0)
goto errout;
}
if (type > maxtype)
continue;
tb[type] = nla;
if (policy) {
err = validate_nla(nla, maxtype, policy);
if (err < 0)
goto errout;
}
if (tb[type])
NL_DBG(1, "Attribute of type %#x found multiple times in message, "
"previous attribute is being ignored.\n", type);
tb[type] = nla;
}
if (rem > 0)