From a0b8690230ad07647c286de514d71758696ff716 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 23 May 2002 06:10:56 +0000 Subject: [PATCH] The "fname" argument to "save_cap_file()", and "cf->filename" - and thus "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. svn path=/trunk/; revision=5526 --- file.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/file.c b/file.c index b27be80881..73bd74d0ef 100644 --- 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 @@ -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