forked from osmocom/wireshark
Patches from Andreas Sikkema:
On Win32, always save a temporary capture file by copying - Win32 systems don't allow you to rename a file that is open, and we have the temporary file open. When saving by copying the raw bytes of a capture file, create the target file with "open()", using the O_BINARY flag, rather than with "creat()"; on Win32 systems, "creat()" apparently opens the file as a text file rather than a binary file. svn path=/trunk/; revision=1757
This commit is contained in:
parent
67d2ea7af0
commit
e386451345
5
AUTHORS
5
AUTHORS
|
@ -276,6 +276,11 @@ Doug Nazar <nazard@dragoninc.on.ca> {
|
||||||
LDAP support
|
LDAP support
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Andreas Sikkema <andreas.sikkema@philips.com> {
|
||||||
|
Fixes to SMB dissector
|
||||||
|
Fixes to capture file handling on Win32
|
||||||
|
}
|
||||||
|
|
||||||
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
|
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
|
||||||
give his permission to use his version of snprintf.c.
|
give his permission to use his version of snprintf.c.
|
||||||
|
|
||||||
|
|
|
@ -837,6 +837,7 @@ B<http://ethereal.zing.org>.
|
||||||
Jochen Friedrich <jochen+ethereal@scram.de>
|
Jochen Friedrich <jochen+ethereal@scram.de>
|
||||||
Paul Welchinski <paul.welchinski@telusplanet.net>
|
Paul Welchinski <paul.welchinski@telusplanet.net>
|
||||||
Doug Nazar <nazard@dragoninc.on.ca>
|
Doug Nazar <nazard@dragoninc.on.ca>
|
||||||
|
Andreas Sikkema <andreas.sikkema@philips.com>
|
||||||
|
|
||||||
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
|
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
|
||||||
permission to use his version of snprintf.c.
|
permission to use his version of snprintf.c.
|
||||||
|
|
15
file.c
15
file.c
|
@ -1,7 +1,7 @@
|
||||||
/* file.c
|
/* file.c
|
||||||
* File I/O routines
|
* File I/O routines
|
||||||
*
|
*
|
||||||
* $Id: file.c,v 1.172 2000/03/26 07:03:52 sharpe Exp $
|
* $Id: file.c,v 1.173 2000/03/28 08:11:43 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -1410,6 +1410,7 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
|
||||||
/* The file being saved is a temporary file from a live
|
/* The file being saved is a temporary file from a live
|
||||||
capture, so it doesn't need to stay around under that name;
|
capture, so it doesn't need to stay around under that name;
|
||||||
first, try renaming the capture buffer file to the new name. */
|
first, try renaming the capture buffer file to the new name. */
|
||||||
|
#ifndef WIN32
|
||||||
if (rename(cf->filename, fname) == 0) {
|
if (rename(cf->filename, fname) == 0) {
|
||||||
/* That succeeded - there's no need to copy the source file. */
|
/* That succeeded - there's no need to copy the source file. */
|
||||||
from_filename = NULL;
|
from_filename = NULL;
|
||||||
|
@ -1434,13 +1435,16 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
do_copy = TRUE;
|
||||||
|
from_filename = cf->filename;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* It's a permanent file, so we should copy it, and not remove the
|
/* It's a permanent file, so we should copy it, and not remove the
|
||||||
original. */
|
original. */
|
||||||
do_copy = TRUE;
|
do_copy = TRUE;
|
||||||
from_filename = cf->filename;
|
from_filename = cf->filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the file, if we haven't moved it. */
|
/* Copy the file, if we haven't moved it. */
|
||||||
if (do_copy) {
|
if (do_copy) {
|
||||||
/* Copy the raw bytes of the file. */
|
/* Copy the raw bytes of the file. */
|
||||||
|
@ -1452,7 +1456,12 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_fd = creat(fname, 0644);
|
/* Use open() instead of creat() so that we can pass the O_BINARY
|
||||||
|
flag, which is relevant on Win32; it appears that "creat()"
|
||||||
|
may open the file in text mode, not binary mode, but we want
|
||||||
|
to copy the raw bytes of the file, so we need the output file
|
||||||
|
to be open in binary mode. */
|
||||||
|
to_fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
|
||||||
if (to_fd < 0) {
|
if (to_fd < 0) {
|
||||||
err = errno;
|
err = errno;
|
||||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||||
|
|
Loading…
Reference in New Issue