diff options
author | Jakob Schlyter <jakob@cvs.openbsd.org> | 2000-12-05 08:17:46 +0000 |
---|---|---|
committer | Jakob Schlyter <jakob@cvs.openbsd.org> | 2000-12-05 08:17:46 +0000 |
commit | 2f30615cf99a513f2d8a46a33b9e991fff96fca8 (patch) | |
tree | b20edab172eb60b8e68f54b09cb9d40084f29844 /usr.sbin/tcpdump/print-tcp.c | |
parent | 788722f908f809300a1cc2a77416e26d0952b3c6 (diff) |
tcpdump incorrectly print port numbers when parsing NFS (PR#1540)
fix submitted by Grigoriy Orlov <gluk@ptci.ru>
Diffstat (limited to 'usr.sbin/tcpdump/print-tcp.c')
-rw-r--r-- | usr.sbin/tcpdump/print-tcp.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index aa47da701b1..c0cd9f7701f 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-tcp.c,v 1.12 2000/10/03 14:21:56 ho Exp $ */ +/* $OpenBSD: print-tcp.c,v 1.13 2000/12/05 08:17:45 jakob Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.12 2000/10/03 14:21:56 ho Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.13 2000/12/05 08:17:45 jakob Exp $ (LBL)"; #endif #include <sys/param.h> @@ -205,26 +205,6 @@ tcp_print(register const u_char *bp, register u_int length, urp = ntohs(tp->th_urp); hlen = tp->th_off * 4; - /* - * If data present and NFS port used, assume NFS. - * Pass offset of data plus 4 bytes for RPC TCP msg length - * to NFS print routines. - */ - if (!qflag) { - u_int len = length - hlen; - if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && - dport == NFS_PORT) { - nfsreq_print((u_char *)tp + hlen + 4, len, - (u_char *)ip); - return; - } - else if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && - sport == NFS_PORT) { - nfsreply_print((u_char *)tp + hlen + 4, len, - (u_char *)ip); - return; - } - } #ifdef INET6 if (ip6) { @@ -256,6 +236,24 @@ tcp_print(register const u_char *bp, register u_int length, if (qflag) { (void)printf("tcp %d", length - tp->th_off * 4); return; + } else { + /* + * If data present and NFS port used, assume NFS. + * Pass offset of data plus 4 bytes for RPC TCP msg length + * to NFS print routines. + */ + u_int len = length - hlen; + if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && + dport == NFS_PORT) { + nfsreq_print((u_char *)tp + hlen + 4, len, + (u_char *)ip); + return; + } else if ((u_char *)tp + 4 + + sizeof(struct rpc_msg) <= snapend && sport == NFS_PORT) { + nfsreply_print((u_char *)tp + hlen + 4, len, + (u_char *)ip); + return; + } } if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH| TH_ECNECHO|TH_CWR)) { |