summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/attr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/attr.c b/lib/attr.c
index 298fbb14..83943307 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -800,6 +800,9 @@ struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen)
struct nlattr *nla;
int tlen;
+ if (attrlen < 0)
+ return NULL;
+
tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
if ((tlen + msg->nm_nlh->nlmsg_len) > msg->nm_size)
@@ -838,6 +841,9 @@ int nla_put(struct nl_msg *msg, int attrtype, int datalen, const void *data)
{
struct nlattr *nla;
+ if (datalen < 0)
+ return -NLE_RANGE;
+
nla = nla_reserve(msg, attrtype, datalen);
if (!nla)
return -NLE_NOMEM;