aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@ns.aus.com>2002-07-21 16:54:22 +0000
committerRichard Sharpe <sharpe@ns.aus.com>2002-07-21 16:54:22 +0000
commitb5fa2524e6592f34413302c5e680f210203126e0 (patch)
tree69b2849ae59d6c89cac1bbc4581c6f23f66f530b
parent52896da39eefca930577d5b9574748ac9eb7f056 (diff)
Fix the problems WRT overwriting a capture file. From Joerg Mayer.
svn path=/trunk/; revision=5898
-rw-r--r--file.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/file.c b/file.c
index a08c3f0cde..995ceb77f5 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.282 2002/07/16 07:15:04 guy Exp $
+ * $Id: file.c,v 1.283 2002/07/21 16:54:22 sharpe Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1725,6 +1725,7 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
struct wtap_pkthdr hdr;
union wtap_pseudo_header pseudo_header;
guint8 pd[65536];
+ struct stat infile, outfile;
name_ptr = get_basename(fname);
msg_len = strlen(name_ptr) + strlen(save_fmt) + 2;
@@ -1736,8 +1737,15 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
/*
* Check that the from file is not the same as to file
* We do it here so we catch all cases ...
+ * Unfortunately, the file requester gives us an absolute file
+ * name and the read file name may be relative (if supplied on
+ * the command line). From Joerg Mayer.
*/
- if (strcmp(cf->filename, fname) == 0) {
+ infile.st_ino = 1; /* These prevent us from getting equality */
+ outfile.st_ino = 2; /* If one or other of the files is not accessible */
+ stat(cf->filename, &infile);
+ stat(fname, &outfile);
+ if (infile.st_ino == outfile.st_ino) {
simple_dialog(ESD_TYPE_CRIT, NULL,
"Can't save over current capture file: %s!",
cf->filename);