summaryrefslogtreecommitdiffstats
path: root/src/msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/msg.c')
-rw-r--r--src/msg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/msg.c b/src/msg.c
index 2a2f830..13d9abc 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -130,12 +130,15 @@ void *mnl_nlmsg_get_data_offset(const struct nlmsghdr *nlh, int offset)
* message has enough room for the netlink message that it stores, ie. this
* function can be used to verify that a netlink message is not malformed nor
* truncated.
+ *
+ * The @len parameter may become negative in malformed messages during message
+ * iteration, that is why we use a signed integer.
*/
int mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len)
{
- return len >= sizeof(struct nlmsghdr) &&
+ return len >= (int)sizeof(struct nlmsghdr) &&
nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
- nlh->nlmsg_len <= len;
+ (int)nlh->nlmsg_len <= len;
}
/**