summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-03-19 12:17:08 +0000
committerFelix Fietkau2025-03-19 12:17:08 +0000
commitc0df580adbd4d555ecc1962dbe88e91d75b67a4e (patch)
tree3c9ee64e314e7e084e96b3530aa7382c3d551a89
parent965c4bf49658342ced0bd6e7cb069571b4a1ddff (diff)
downloadlibnl-tiny-c0df580adbd4d555ecc1962dbe88e91d75b67a4e.tar.gz
attr.c: fix nla_reserve size check
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--attr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/attr.c b/attr.c
index 2c1d354..d251c25 100644
--- a/attr.c
+++ b/attr.c
@@ -618,11 +618,11 @@ struct nlattr *nla_find(struct nlattr *head, int len, int attrtype)
struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen)
{
struct nlattr *nla;
- int tlen;
-
+ size_t tlen;
+
tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
- if ((tlen + msg->nm_nlh->nlmsg_len) > msg->nm_size)
+ if (tlen > msg->nm_size || tlen > UINT32_MAX)
return NULL;
nla = (struct nlattr *) nlmsg_tail(msg->nm_nlh);