]> The Tcpdump Group git mirrors - tcpdump/commitdiff
reset the counter after a -G rollover (GH #352)
authorzolf <[email protected]>
Sun, 5 Jan 2014 21:28:54 +0000 (22:28 +0100)
committerDenis Ovsienko <[email protected]>
Fri, 10 Jan 2014 09:47:03 +0000 (13:47 +0400)
when -G -C is used the filename counter continued. Changed the behaviour
so that when -G is rolled over to the next file the Cflag-counter is
reset to 0 so that the filenames will restart counting.

tcpdump.c

index 9834a51e26ddbcf5dc4c742e7dc36e217f7edcf9..da0402805eef9afe10276559b609a6f0c3d6a66b 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1847,6 +1847,13 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
                        dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1);
                        if (dump_info->CurrentFileName == NULL)
                                error("dump_packet_and_trunc: malloc");
+                       /*
+                        * Gflag was set otherwise we wouldn't be here. Reset the count
+                        * so multiple files would end with 1,2,3 in the filename.
+                        * The counting is handled with the -C flow after this.
+                        */
+                       Cflag_count = 0;
+
                        /*
                         * This is always the first file in the Cflag
                         * rotation: e.g. 0