diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2015-11-15 10:02:02 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-11-16 10:05:01 +0100 |
commit | 6b0e119ae85aad5f2582159fe68e91adb4b02dbd (patch) | |
tree | 6d2e6730e0700b480a380ed550d114f7188d9a04 /proto_nlmsg.c | |
parent | a109a26b36f0b2244aa89886f58b239017991f69 (diff) |
netsniff-ng: nlmsg: Check message length before dissect rtnl
Do not print rtnl message if there is only nlmsg header, which is happen
when dump all rtnl table.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'proto_nlmsg.c')
-rw-r--r-- | proto_nlmsg.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/proto_nlmsg.c b/proto_nlmsg.c index 93c52b9..c9238c8 100644 --- a/proto_nlmsg.c +++ b/proto_nlmsg.c @@ -293,6 +293,9 @@ static void rtnl_print_ifinfo(struct nlmsghdr *hdr) char if_addr[64] = {}; char *af_link = "unknown"; + if (hdr->nlmsg_len < NLMSG_LENGTH(sizeof(*ifi))) + return; + if (ifi->ifi_family == AF_UNSPEC) af_link = "unspec"; else if (ifi->ifi_family == AF_BRIDGE) @@ -398,6 +401,9 @@ static void rtnl_print_ifaddr(struct nlmsghdr *hdr) char addr_str[256]; char flags[256]; + if (hdr->nlmsg_len < NLMSG_LENGTH(sizeof(*ifa))) + return; + tprintf(" [ Address Family %d (%s%s%s)", ifa->ifa_family, colorize_start(bold), addr_family2str(ifa->ifa_family), @@ -555,6 +561,9 @@ static void rtnl_print_route(struct nlmsghdr *hdr) char addr_str[256]; char flags[256]; + if (hdr->nlmsg_len < NLMSG_LENGTH(sizeof(*rtm))) + return; + tprintf(" [ Route Family %d (%s%s%s)", rtm->rtm_family, colorize_start(bold), addr_family2str(rtm->rtm_family), @@ -698,6 +707,9 @@ static void rtnl_print_neigh(struct nlmsghdr *hdr) char states[256]; char flags[256]; + if (hdr->nlmsg_len < NLMSG_LENGTH(sizeof(*ndm))) + return; + tprintf(" [ Neigh Family %d (%s%s%s)", ndm->ndm_family, colorize_start(bold), addr_family2str(ndm->ndm_family), |