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-Tag: tcpdump-4.2.1~101 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/768c379e643e28184fe267700859a698cc90faf8?ds=inline 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 a89a2f1d..e75b65f2 100644 --- a/CREDITS +++ b/CREDITS @@ -155,6 +155,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 b26188f5..2f120396 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1212,6 +1212,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;