It would be better to use NLMSG_HDRLEN instead of sizeof(*hdr) and not to use NLMSG_PAYLOAD to get payload length, I think.
Signed-off-by: Ken-ichirou MATSUZAWA <cha...@h4.dion.ne.jp> --- proto_nlmsg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proto_nlmsg.c b/proto_nlmsg.c index 1dde5e1..76253ca 100644 --- a/proto_nlmsg.c +++ b/proto_nlmsg.c @@ -750,15 +750,15 @@ static void nlmsg_print(uint16_t family, struct nlmsghdr *hdr) static void nlmsg(struct pkt_buff *pkt) { - struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr)); + struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN); while (hdr) { nlmsg_print(ntohs(pkt->sll->sll_protocol), hdr); - if (!pkt_pull(pkt, NLMSG_PAYLOAD(hdr, 0))) + if (!pkt_pull(pkt, NLMSG_ALIGN(hdr->nlmsg_len) - NLMSG_HDRLEN)) break; - hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr)); + hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN); if (hdr && hdr->nlmsg_type != NLMSG_DONE && (hdr->nlmsg_flags & NLM_F_MULTI)) tprintf("\n"); @@ -767,7 +767,7 @@ static void nlmsg(struct pkt_buff *pkt) static void nlmsg_less(struct pkt_buff *pkt) { - struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr)); + struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN); uint16_t family = ntohs(pkt->sll->sll_protocol); char type[32]; -- 2.1.4 -- You received this message because you are subscribed to the Google Groups "netsniff-ng" group. To unsubscribe from this group and stop receiving emails from it, send an email to netsniff-ng+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.