Make sure that when we save a file, we don't overwrite our capture file
authorsharpe <sharpe@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 22 Apr 2002 19:10:33 +0000 (19:10 +0000)
committersharpe <sharpe@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 22 Apr 2002 19:10:33 +0000 (19:10 +0000)
with an empty file.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5225 f5534014-38df-0310-8fa8-9805f1628bb7

file.c

diff --git a/file.c b/file.c
index e6927bb29a8ef9a96c81122d0717eac030b2dcf6..16319e06bc0456274ae800865c31a53b932ce577 100644 (file)
--- 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 <gerald@ethereal.com>
@@ -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;
            }