]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Check whether we have too many output files *before* allocating the
authorguy <guy>
Mon, 26 Jan 2004 01:59:45 +0000 (01:59 +0000)
committerguy <guy>
Mon, 26 Jan 2004 01:59:45 +0000 (01:59 +0000)
buffer for the new output file name.

tcpdump.c

index a1e46c62f5360884d1d2d38dd9735b3706e6e8e5..9d26535322a7249b4e65b7caf6236a2c17da0967 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.216.2.8 2004-01-26 01:42:18 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216.2.9 2004-01-26 01:59:45 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -945,12 +945,12 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
                 * Close the current file and open a new one.
                 */
                pcap_dump_close(dump_info->p);
+               if (cnt >= 1000)
+                       error("too many output files");
                name = (char *) malloc(strlen(dump_info->WFileName) + 4);
                if (name == NULL)
                        error("dump_packet_and_trunc: malloc");
                strcpy(name, dump_info->WFileName);
-               if (cnt >= 1000)
-                       error("too many output files");
                swebitoa(cnt, name + strlen(dump_info->WFileName));
                cnt++;
                dump_info->p = pcap_dump_open(dump_info->pd, name);