The "fname" argument to "save_cap_file()", and "cf->filename" - and thus
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 23 May 2002 06:10:56 +0000 (06:10 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 23 May 2002 06:10:56 +0000 (06:10 +0000)
"from_filename" - are both null-terminated strings; compare them with
"strcmp", not "strncmp()".  ("cf->filename" is a "char *", so
"sizeof(cf->filename)" is not the right third argument to "strncmp()" in
any case, as it's the size of a pointer, which is probably either 4 or 8
bytes.)

Make the dialog box for "Can't save over current capture file" an
ESD_TYPE_CRIT dialog box, as it's a fatal error.

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

file.c

diff --git a/file.c b/file.c
index b27be808818ce88b520c37bb20b578eeb33f21b9..73bd74d0ef20f22fffaed2b456a28b003b77b4a0 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.272 2002/05/03 21:55:12 guy Exp $
+ * $Id: file.c,v 1.273 2002/05/23 06:10:56 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -1782,20 +1782,19 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered, gboolean sa
       from_filename = cf->filename;
     }
 
-    /* Check that the from file is not the same as to file */
-
     if (do_copy) {
+      /* Check that the from file is not the same as to file */
+      if (strcmp(from_filename, fname) == 0) {
+       simple_dialog(ESD_TYPE_CRIT, NULL, 
+                       "Can't save over current capture file: %s!",
+                       from_filename);
+       goto done;
+      }
 
-            /* 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;
-           }
+      /* Copy the file, if we haven't moved it. */
+      if (!copy_binary_file(from_filename, fname)) {
+       goto done;
+      }
     }
   } else {
     /* Either we're filtering packets, or we're saving in a different