summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-udp.c
diff options
context:
space:
mode:
authorpkelsey <pkelsey@FreeBSD.org>2015-07-08 16:19:32 +0000
committerpkelsey <pkelsey@FreeBSD.org>2015-07-08 16:19:32 +0000
commit7e965066ede451d7a551dd68d6c59acf32e4846e (patch)
treef0c2243cc0a2a59f3eb1354ba3987d4cbcb788bc /contrib/tcpdump/print-udp.c
parent732211dc794db586649eabfc1d517b8a477440f5 (diff)
parentc2704d8ede887d9fe69a9a11fe0755b09ec6895d (diff)
downloadFreeBSD-src-7e965066ede451d7a551dd68d6c59acf32e4846e.zip
FreeBSD-src-7e965066ede451d7a551dd68d6c59acf32e4846e.tar.gz
MFV r285191: tcpdump 4.7.4.
Also, the changes made in r272451 and r272653 that were lost in the merge of 4.6.2 (r276788) have been restored. PR: 199568 Differential Revision: https://reviews.freebsd.org/D3007 Reviewed by: brooks, hiren Approved by: jmallett (mentor) MFC after: 1 month
Diffstat (limited to 'contrib/tcpdump/print-udp.c')
-rw-r--r--contrib/tcpdump/print-udp.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index 58be945..c9e6058 100644
--- a/contrib/tcpdump/print-udp.c
+++ b/contrib/tcpdump/print-udp.c
@@ -45,7 +45,6 @@
#include "nameser.h"
#include "nfs.h"
-#include "bootp.h"
struct rtcphdr {
uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
@@ -370,7 +369,6 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
else
ip6 = NULL;
#endif /*INET6*/
- cp = (u_char *)(up + 1);
if (!ND_TTEST(up->uh_dport)) {
udpipaddr_print(ndo, ip, -1, -1);
ND_PRINT((ndo, "[|udp]"));
@@ -385,20 +383,24 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
ND_PRINT((ndo, "truncated-udp %d", length));
return;
}
+ ulen = EXTRACT_16BITS(&up->uh_ulen);
+ if (ulen < sizeof(struct udphdr)) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ ND_PRINT((ndo, "truncated-udplength %d", ulen));
+ return;
+ }
+ ulen -= sizeof(struct udphdr);
length -= sizeof(struct udphdr);
+ if (ulen < length)
+ length = ulen;
+ cp = (u_char *)(up + 1);
if (cp > ndo->ndo_snapend) {
udpipaddr_print(ndo, ip, sport, dport);
ND_PRINT((ndo, "[|udp]"));
return;
}
- ulen = EXTRACT_16BITS(&up->uh_ulen);
- if (ulen < 8) {
- udpipaddr_print(ndo, ip, sport, dport);
- ND_PRINT((ndo, "truncated-udplength %d", ulen));
- return;
- }
if (ndo->ndo_packettype) {
register struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
@@ -444,7 +446,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
case PT_CNFP:
udpipaddr_print(ndo, ip, sport, dport);
- cnfp_print(ndo, cp, (const u_char *)ip);
+ cnfp_print(ndo, cp);
break;
case PT_TFTP:
@@ -573,7 +575,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
timed_print(ndo, (const u_char *)(up + 1));
else if (ISPORT(TFTP_PORT))
tftp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
+ else if (ISPORT(BOOTPC_PORT) || ISPORT(BOOTPS_PORT))
bootp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(RIP_PORT))
rip_print(ndo, (const u_char *)(up + 1), length);
@@ -638,7 +640,8 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
else if (ISPORT(RADIUS_PORT) ||
ISPORT(RADIUS_NEW_PORT) ||
ISPORT(RADIUS_ACCOUNTING_PORT) ||
- ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
+ ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ||
+ ISPORT(RADIUS_COA_PORT) )
radius_print(ndo, (const u_char *)(up+1), length);
else if (dport == HSRP_PORT)
hsrp_print(ndo, (const u_char *)(up + 1), length);
@@ -678,12 +681,23 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
otv_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(VXLAN_PORT))
vxlan_print(ndo, (const u_char *)(up + 1), length);
- else
- ND_PRINT((ndo, "UDP, length %u",
- (uint32_t)(ulen - sizeof(*up))));
+ else if (ISPORT(GENEVE_PORT))
+ geneve_print(ndo, (const u_char *)(up + 1), length);
+ else {
+ if (ulen > length)
+ ND_PRINT((ndo, "UDP, bad length %u > %u",
+ ulen, length));
+ else
+ ND_PRINT((ndo, "UDP, length %u", ulen));
+ }
#undef ISPORT
- } else
- ND_PRINT((ndo, "UDP, length %u", (uint32_t)(ulen - sizeof(*up))));
+ } else {
+ if (ulen > length)
+ ND_PRINT((ndo, "UDP, bad length %u > %u",
+ ulen, length));
+ else
+ ND_PRINT((ndo, "UDP, length %u", ulen));
+ }
}
OpenPOWER on IntegriCloud