summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Stewart <pstew@google.com>2016-10-28 16:31:40 -0700
committergitbuildkicker <android-build@google.com>2016-11-30 12:11:26 -0800
commitef6f663d4c9d3f399226da8aa75f0081a965874d (patch)
tree04fa4ac4fae8a79fa7d78ea929090a6f2a726192
parent8ff83230ff3e5030bf2145717648db66ba6df969 (diff)
downloadlibnl-ef6f663d4c9d3f399226da8aa75f0081a965874d.tar.gz
Ensure predictable behavior when negative values are passed to these methods. Bug: 32255299 Change-Id: I14d2e4a65e5b208554821f9d3ed4e3244464dfd6 Test: Recompile (integration tests will also run) (cherry picked from commit f01b03b81ab86d2b4c0f874a438ff672d9fcc191)
-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;