From: sharpe Date: Mon, 22 Apr 2002 19:10:33 +0000 (+0000) Subject: Make sure that when we save a file, we don't overwrite our capture file X-Git-Url: http://git.samba.org/samba.git/?p=obnox%2Fwireshark%2Fwip.git;a=commitdiff_plain;h=29c061d7ce1cca896e71aeea0a281035992476d4;ds=sidebyside Make sure that when we save a file, we don't overwrite our capture file with an empty file. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5225 f5534014-38df-0310-8fa8-9805f1628bb7 --- diff --git a/file.c b/file.c index e6927bb29a..16319e06bc 100644 --- a/file.c +++ b/file.c @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.268 2002/04/20 01:54:27 guy Exp $ + * $Id: file.c,v 1.269 2002/04/22 19:10:33 sharpe Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1750,8 +1750,18 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered, gboolean sa do_copy = TRUE; from_filename = cf->filename; } - /* Copy the file, if we haven't moved it. */ + + /* Check that the from file is not the same as to file */ + if (do_copy) { + + /* Copy the file, if we haven't moved it. */ + if (strncmp(from_filename, fname, sizeof(cf->filename)) == 0) { + simple_dialog(ESD_TYPE_WARN, NULL, + "Can't save over current capture file: %s!", from_filename); + goto done; + } + if (!copy_binary_file(from_filename, fname)) { goto done; }