Unfortunately, I haven't found the time to allow overwriting by using an
intermediate file, so this is just the patch I submitted last time that
disallows writing over the current capture file.
Ciao
Jörg
--
Joerg Mayer <jmayer@xxxxxxxxx>
I found out that "pro" means "instead of" (as in proconsul). Now I know
what proactive means.
Changelog: <jmayer@xxxxxxxxx>
file.c: Fix file corrution in case of overwriting the input file
by disallowing that. I'm leaving the old code in for now as
I don't know whether it will be needed on Windows.
Index: ethereal/file.c
===================================================================
RCS file: /cvsroot/ethereal/file.c,v
retrieving revision 1.282
diff -u -r1.282 file.c
--- file.c 2002/07/16 07:15:04 1.282
+++ file.c 2002/07/17 07:48:24
@@ -1725,6 +1725,7 @@
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;
@@ -1737,12 +1740,30 @@
* Check that the from file is not the same as to file
* We do it here so we catch all cases ...
*/
+#if 0
if (strcmp(cf->filename, fname) == 0) {
simple_dialog(ESD_TYPE_CRIT, NULL,
"Can't save over current capture file: %s!",
cf->filename);
goto fail;
}
+#else
+ /*
+ * Unfortunately, the file requester gives us an absolute file
+ * name and the read file name may be relative (if supplied on
+ * the command line).
+ */
+ infile.st_ino = 1;
+ outfile.st_ino = 2;
+ 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);
+ goto fail;
+ }
+#endif
if (!save_filtered && !save_marked && save_format == cf->cd_t) {
/* We're not filtering packets, and we're saving it in the format