summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2013-03-13 17:12:03 +0100
committerThomas Graf <tgraf@suug.ch>2013-03-14 12:46:09 +0100
commit1395c69901834f66e1e1522d5253a84b45901066 (patch)
treeced0b1215e48a4aef7a23b395d35e797c4b996f9
parent64315f731cedb3ca1736533dab92592c330a1083 (diff)
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>
-rw-r--r--lib/attr.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/attr.c b/lib/attr.c
index 093ffb5..e6efe4e 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -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;
- }
-
- tb[type] = nla;
+ if (type > maxtype)
+ continue;
+
+ 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)