From d880bb845c93761c0ab028e6f9ec31f2c43edb1a Mon Sep 17 00:00:00 2001 From: laforge Date: Thu, 16 Oct 2003 12:56:59 +0000 Subject: fix output if file exists and has a size of zero bytes (Yoshihiro Kawabe) --- ulogd/pcap/ulogd_PCAP.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ulogd/pcap') diff --git a/ulogd/pcap/ulogd_PCAP.c b/ulogd/pcap/ulogd_PCAP.c index 7178b11..56c50f8 100644 --- a/ulogd/pcap/ulogd_PCAP.c +++ b/ulogd/pcap/ulogd_PCAP.c @@ -1,4 +1,4 @@ -/* ulogd_PCAP.c, Version $Revision: 1.5 $ +/* ulogd_PCAP.c, Version $Revision: 1.6 $ * * ulogd output target for writing pcap-style files (like tcpdump) * @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ulogd_PCAP.c,v 1.5 2003/08/23 17:25:59 laforge Exp $ + * $Id: ulogd_PCAP.c,v 1.6 2003/09/28 15:19:27 laforge Exp $ * */ @@ -154,8 +154,13 @@ static int get_ids(void) void append_create_outfile(void) { struct stat st_dummy; + int exist = 0; - if (stat(pcapf_ce.u.string, &st_dummy)) { + if (stat(pcapf_ce.u.string, &st_dummy) == 0 && st.st_size > 0) { + exist = 1; + } + + if (!exist) { of = fopen(pcapf_ce.u.string, "w"); if (!of) { ulogd_log(ULOGD_FATAL, "can't open pcap file: %s\n", -- cgit v1.2.3