]> The Tcpdump Group git mirrors - tcpdump/commitdiff
make `-s 0' mean try to use the maximum required snaplen. based on a
authorassar <assar>
Fri, 21 Apr 2000 10:32:03 +0000 (10:32 +0000)
committerassar <assar>
Fri, 21 Apr 2000 10:32:03 +0000 (10:32 +0000)
patch from "Gilbert Ramirez Jr." <[email protected]>

tcpdump.c

index 69c7dbaafd99b16eef5277e7ce7bc90476de4e80..f6d8860ee28c35912633c3539850fd3b9a61d81c 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -24,7 +24,7 @@ static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.143 2000-01-29 21:00:59 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.144 2000-04-21 10:32:03 assar Exp $ (LBL)";
 #endif
 
 /*
@@ -263,11 +263,17 @@ main(int argc, char **argv)
                        Rflag = 0;
                        break;
 
-               case 's':
-                       snaplen = atoi(optarg);
-                       if (snaplen <= 0)
+               case 's': {
+                       char *end;
+
+                       snaplen = strtol(optarg, &end, 0);
+                       if (optarg == end || *end != '\0'
+                           || snaplen < 0 || snaplen > 65535)
                                error("invalid snaplen %s", optarg);
+                       else if (snaplen == 0)
+                               snaplen = 65535;
                        break;
+               }
 
                case 'S':
                        ++Sflag;