diff options
author | Thomas Haller <thaller@redhat.com> | 2017-01-18 10:59:23 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-01-18 11:30:26 (GMT) |
commit | c473d59f972c35c5a7363d52ee6ee1e0792de0f8 (patch) | |
tree | d3ef81aa879df490138eeca14f2c98ceb75f4483 /lib | |
parent | 64b12a065ae4fb84ae92299037c7eb8526549c85 (diff) | |
download | libnl-c473d59f972c35c5a7363d52ee6ee1e0792de0f8.zip libnl-c473d59f972c35c5a7363d52ee6ee1e0792de0f8.tar.gz libnl-c473d59f972c35c5a7363d52ee6ee1e0792de0f8.tar.bz2 |
lib/attr.c: check for valid length argument in nla_reserve()
https://github.com/thom311/libnl/issues/124
Diffstat (limited to 'lib')
-rw-r--r-- | lib/attr.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -457,7 +457,10 @@ 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_size) @@ -499,8 +502,12 @@ int nla_put(struct nl_msg *msg, int attrtype, int datalen, const void *data) struct nlattr *nla; nla = nla_reserve(msg, attrtype, datalen); - if (!nla) + if (!nla) { + if (datalen < 0) + return -NLE_INVAL; + return -NLE_NOMEM; + } if (datalen > 0) { memcpy(nla_data(nla), data, datalen); |