]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Fix 64-bit maximum file size argument stuff.
authorGuy Harris <[email protected]>
Fri, 20 Oct 2017 19:15:26 +0000 (12:15 -0700)
committerGuy Harris <[email protected]>
Fri, 20 Oct 2017 19:15:26 +0000 (12:15 -0700)
Define strtoint64_t as appropriate in netdissect-stdinc.h.

Check HAVE_PCAP_DUMP_FTELL64, not HAVE_PCAP_FTELL64, to see whether we
have pcap_dump_ftell64().

netdissect-stdinc.h
tcpdump.c

index da1d8dcd5ff706bc010410531a4013263947ca6e..ab7ddcf98db302b6e41ceaba9c982b79f01018c4 100644 (file)
         typedef unsigned long long uint64_t;
         typedef long long int64_t;
       #endif
+
+      /*
+       * We have _strtoi64().  Use that for strtoint64_t().
+       */
+      #define strtoint64_t     _strtoi64
     #endif
 
     /*
 #ifdef _MSC_VER
   /*
    * Compiler is MSVC.
-   *
+   */
+  #if _MSC_VER >= 1800
+    /*
+     * VS 2013 or newer; we have strtoll().  Use that for strtoint64_t().
+     */
+    #define strtoint64_t       strtoll
+  #else
+    /*
+     * Earlier VS; we don't have strtoll(), but we do have
+     * _strtoi64().  Use that for strtoint64_t().
+     */
+    #define strtoint64_t       _strtoi64
+  #endif
+
+  /*
    * Microsoft's documentation doesn't speak of LL as a valid
    * suffix for 64-bit integers, so we'll just use i64.
    */
   #define INT64_T_CONSTANT(constant)   (constant##i64)
 #else
   /*
-   * Non-Microsoft compiler; assume LL works.
+   * Non-Microsoft compiler.
+   *
+   * XXX - should we use strtoll or should we use _strtoi64()?
+   */
+  #define strtoint64_t         strtoll
+
+  /*
+   * Assume LL works.
    */
   #define INT64_T_CONSTANT(constant)   (constant##LL)
 #endif
@@ -235,6 +261,11 @@ typedef char* caddr_t;
 
 #include <arpa/inet.h>
 
+/*
+ * Assume all UN*Xes have strtoll(), and use it for strtoint64_t().
+ */
+#define strtoint64_t   strtoll
+
 /*
  * Assume LL works.
  */
index 695cedb7fe53c2401f45662e65836e0352e89484..53eff2ac5ae45cf9c0b79017998bf4e32239d3a0 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -142,7 +142,7 @@ The Regents of the University of California.  All rights reserved.\n";
 #endif
 
 static int Bflag;                      /* buffer size */
-#ifdef HAVE_PCAP_FTELL64
+#ifdef HAVE_PCAP_DUMP_FTELL64
 static int64_t Cflag;                  /* rotate dump files after this many bytes */
 #else
 static long Cflag;                     /* rotate dump files after this many bytes */
@@ -1385,7 +1385,7 @@ main(int argc, char **argv)
 
                case 'C':
                        errno = 0;
-#ifdef HAVE_PCAP_FTELL64
+#ifdef HAVE_PCAP_DUMP_FTELL64
                        Cflag = strtoint64_t(optarg, &endp, 10);
 #else
                        Cflag = strtol(optarg, &endp, 10);
@@ -1396,7 +1396,7 @@ main(int argc, char **argv)
                        /*
                         * Will multiplying it by 1000000 overflow?
                         */
-#ifdef HAVE_PCAP_FTELL64
+#ifdef HAVE_PCAP_DUMP_FTELL64
                        if (Cflag > INT64_T_CONSTANT(0x7fffffffffffffffU) / 1000000)
 #else
                        if (Cflag > LONG_MAX / 1000000)
@@ -2658,7 +2658,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
         * file could put it over Cflag.
         */
        if (Cflag != 0) {
-#ifdef HAVE_PCAP_FTELL64
+#ifdef HAVE_PCAP_DUMP_FTELL64
                int64_t size = pcap_dump_ftell64(dump_info->p);
 #else
                /*