Patch for unexpectedly aligned messages
I found the following bug, where nlmsg_ok() in lib/msg.c would incorrectly return 'true' when the input argument 'remaining' was a negative number. This happens when the message is not aligned the way that libnl expects (although it is still legal). In the comparison of the signed and unsigned numbers on line 284, the signed number gets converted to an unsigned number, which is unexpected and naturally produces a bug. My patch is below. The cast is ugly, but it fixes the problem.
This commit is contained in:
parent
ef858fb492
commit
1ed227d3a9
1 changed files with 1 additions and 1 deletions
|
@ -284,7 +284,7 @@ int nlmsg_valid_hdr(const struct nlmsghdr *nlh, int hdrlen)
|
|||
*/
|
||||
int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
|
||||
{
|
||||
return (remaining >= sizeof(struct nlmsghdr) &&
|
||||
return (remaining >= (int)sizeof(struct nlmsghdr) &&
|
||||
nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
|
||||
nlh->nlmsg_len <= remaining);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue