X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ee68aa36460d7efeca48747f33b7f2adc0900bfb..10ac80fdecfa9b9b7d259d8f50d0b72ef1b18f12:/print-sflow.c diff --git a/print-sflow.c b/print-sflow.c index 68bca017..ba79e6a6 100644 --- a/print-sflow.c +++ b/print-sflow.c @@ -19,7 +19,7 @@ /* \summary: sFlow protocol printer */ -/* specification: http://www.sflow.org/developers/specifications.php */ +/* specification: https://sflow.org/developers/specifications.php */ #ifdef HAVE_CONFIG_H #include @@ -872,6 +872,12 @@ sflow_print(netdissect_options *ndo, tptr = pptr; tlen = len; sflow_datagram = (const struct sflow_datagram_t *)pptr; + if (len < sizeof(struct sflow_datagram_t)) { + ND_PRINT("sFlowv%u", GET_BE_U_4(sflow_datagram->version)); + ND_PRINT(" [length %u < %zu]", len, sizeof(struct sflow_datagram_t)); + nd_print_invalid(ndo); + return; + } ND_TCHECK_SIZE(sflow_datagram); /* @@ -887,7 +893,7 @@ sflow_print(netdissect_options *ndo, ND_PRINT("sFlowv%u, %s agent %s, agent-id %u, length %u", GET_BE_U_4(sflow_datagram->version), GET_BE_U_4(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6", - ipaddr_string(ndo, sflow_datagram->agent), + GET_IPADDR_STRING(sflow_datagram->agent), GET_BE_U_4(sflow_datagram->agent_id), len); return; @@ -898,7 +904,7 @@ sflow_print(netdissect_options *ndo, ND_PRINT("sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u", GET_BE_U_4(sflow_datagram->version), GET_BE_U_4(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6", - ipaddr_string(ndo, sflow_datagram->agent), + GET_IPADDR_STRING(sflow_datagram->agent), GET_BE_U_4(sflow_datagram->agent_id), GET_BE_U_4(sflow_datagram->seqnum), GET_BE_U_4(sflow_datagram->uptime),