From 73661922bc3b7ebf1225d8273147ab4a87757008 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 5 Apr 2010 17:36:42 +0200 Subject: fix warning in compilation due to different signess MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit msg.c: In function ‘mnl_nlmsg_ok’: msg.c:136: warning: comparison between signed and unsigned msg.c:138: warning: comparison between signed and unsigned attr.c: In function ‘mnl_attr_ok’: attr.c:79: warning: comparison between signed and unsigned Signed-off-by: Pablo Neira Ayuso --- src/msg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/msg.c') 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; } /** -- cgit v1.2.3