From: Romain Francoise Date: Sat, 5 Jun 2010 07:37:27 +0000 (-0700) Subject: If -U is specified, flush the file after creating it, so it's not zero-length. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/e3f30fd4dd84b0f89eefd0d7449e78032b06d797 If -U is specified, flush the file after creating it, so it's not zero-length. Reading from a capture file that has not yet received any packets fails with "truncated dump file"; to avoid this, flush the file (forcing the pcap header out) immediately after opening it. (Added Romain to the credits.) Reviewed-By: Guy Harris --- diff --git a/CREDITS b/CREDITS index 0a3b56eb..db239845 100644 --- a/CREDITS +++ b/CREDITS @@ -154,6 +154,7 @@ Additional people who have contributed patches: Rob Braun Robert Edmonds Roderick Schertler + Romain Francoise Sagun Shakya Sami Farin Scott Rose diff --git a/tcpdump.c b/tcpdump.c index b42509eb..a121d8ba 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1209,6 +1209,10 @@ main(int argc, char **argv) callback = dump_packet; pcap_userdata = (u_char *)p; } +#ifdef HAVE_PCAP_DUMP_FLUSH + if (Uflag) + pcap_dump_flush(p); +#endif } else { type = pcap_datalink(pd); printinfo.ndo_type = 1;