monitor: use int length for NLMSG_NEXT
PATCH 1/2 monitor: use int length for NLMSG_NEXT
In all uses of NLMSG_{NEXT,OK,ALIGN} the length was unsigned which is not what these macros expect. According to the docs the length should be int type, so this was changed for all uses in monitor.
The was causing random, somewhat rare, crashes in nlmon_receive.
--- monitor/main.c | 2 +- monitor/nlmon.c | 6 +++--- monitor/nlmon.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
monitor/main.c +1 -1
@@ -451,7 +451,7 @@ static int analyze_pcap(const char *pathname)while (pcap_read (pcap, &tv, buf, snaplen, &len, &real_len)) {struct nlmsghdr *nlmsg; -uint32_t aligned_len; +int aligned_len;uint16_t arphrd_type;uint16_t proto_type;
monitor/nlmon.c +3 -3
@@ -8080,7 +8080,7 @@ static void print_rtnl_msg(const struct timeval *tv,void nlmon_print_rtnl (struct nlmon *nlmon,const struct timeval *tv,const void *data,uint32_t size) { -uint32_t aligned_size =NLMSG_ALIGN (size); +int aligned_size =NLMSG_ALIGN (size);const struct nlmsghdr *nlmsg;update_time_offset (tv);
@@ -8112,7 +8112,7 @@ void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv, }void nlmon_print_genl (struct nlmon *nlmon,const struct timeval *tv, -const void *data,uint32_t size) +const void *data,int size) {const struct nlmsghdr *nlmsg;
@@ -8144,7 +8144,7 @@ static bool nlmon_receive(struct l_io *io, void *user_data)unsigned char buf[8192 ];unsigned char control[32 ];ssize_t bytes_read; -uint32_t nlmsg_len; +int nlmsg_len;int fd; fd =l_io_get_fd (io);
monitor/nlmon.h +1 -1
@@ -41,7 +41,7 @@ void nlmon_destroy(struct nlmon *nlmon);void nlmon_print_rtnl (struct nlmon *nlmon,const struct timeval *tv,const void *data,uint32_t size);void nlmon_print_genl (struct nlmon *nlmon,const struct timeval *tv, -const void *data,uint32_t size); +const void *data,int size);void nlmon_print_pae (struct nlmon *nlmon,const struct timeval *tv,uint8_t type,int index,const void *data,uint32_t size);
Signature · 1 line
2.34.3
PATCH 2/2 frame-xchg: use int length for NLMSG_* macros
The macro expects an integer type so use that to avoid any unintended behavior as seen in iwmon.
--- src/frame-xchg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/frame-xchg.c +1 -1
@@ -316,7 +316,7 @@ static bool frame_watch_group_io_read(struct l_io *io, void *user_data)unsigned char control[32 ];ssize_t bytes_read;struct nlmsghdr *nlmsg; -size_t nlmsg_len; +int nlmsg_len;uint32_t nlmsg_group =0 ;memset (&iov,0 ,sizeof (iov));
Signature · 1 line
2.34.3