]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
Add bounds checking.
[tcpdump] / tcpdump.c
index 4dc2fe0aa39e4569d758982eb0de21518f71a555..2e1b533d318a42536087c9666407f5d5335b7874 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.235 2004-03-17 19:40:42 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.238 2004-03-23 18:57:33 fenner Exp $ (LBL)";
 #endif
 
 /*
@@ -65,8 +65,10 @@ extern int SIZE_BUF;
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef WIN32
 #include <pwd.h>
 #include <grp.h>
+#endif /* WIN32 */
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -111,6 +113,7 @@ static int WflagChars = 0;
 const char *dlt_name = NULL;
 
 char *espsecret = NULL;                /* ESP secret key */
+char *tcpmd5secret = NULL;     /* TCP-MD5 secret key */
 
 int packettype;
 
@@ -318,6 +321,12 @@ show_dlts_and_exit(pcap_t *pd)
 #define B_FLAG_USAGE
 #endif /* WIN32 */
 
+#ifdef HAVE_PCAP_FINDALLDEVS
+#ifndef HAVE_PCAP_IF_T
+#undef HAVE_PCAP_FINDALLDEVS
+#endif
+#endif
+
 #ifdef HAVE_PCAP_FINDALLDEVS
 #define D_FLAG "D"
 #else
@@ -330,6 +339,7 @@ show_dlts_and_exit(pcap_t *pd)
 #define U_FLAG
 #endif
 
+#ifndef WIN32
 /* Drop root privileges and chroot if necessary */
 static void
 droproot(const char *username, const char *chroot_dir)
@@ -361,6 +371,7 @@ droproot(const char *username, const char *chroot_dir)
                exit(1);
        }
 }
+#endif /* WIN32 */
 
 static int
 getWflagChars(int x)
@@ -433,7 +444,7 @@ main(int argc, char **argv)
 
        opterr = 0;
        while (
-           (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:YZ:")) != -1)
+           (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:YZ:")) != -1)
                switch (op) {
 
                case 'a':
@@ -586,6 +597,14 @@ main(int argc, char **argv)
 #endif
                        break;
 
+               case 'M':
+                       /* TCP-MD5 shared secret */
+#ifndef HAVE_LIBCRYPTO
+                       warning("crypto code not compiled in");
+#endif
+                       tcpmd5secret = optarg;
+                       break;
+
                case 'O':
                        Oflag = 0;
                        break;
@@ -1277,9 +1296,9 @@ usage(void)
        (void)fprintf(stderr,
 "Usage: %s [-aAd" D_FLAG "eflLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name);
        (void)fprintf(stderr,
-"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -r file ]\n");
+"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]\n");
        (void)fprintf(stderr,
-"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ]\n");
+"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ]\n");
        (void)fprintf(stderr,
 "\t\t[ -y datalinktype ] [ -Z user ]\n");
        (void)fprintf(stderr,