aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2018-12-16 21:54:49 +0100
committerAnders Broman <a.broman58@gmail.com>2018-12-17 05:19:09 +0000
commit74bd75baa58f9d569c856493df396e9f813539f5 (patch)
tree6677f0bf77026f57c82de435582fcda31cd1145a /wiretap
parent5009f98c3a7979635435f21fb94913e680ebd9cd (diff)
wiretap: use appropriate extension for temporary files
With the change from Wireshark's default capture file format from pcap to pcapng the suffix of the temporary file created in wiretap was also changed from .pcap to .pcapng. This irrespective of the actual file type requested. This change retrieves the registered extension for the requested file type (in its uncompressed form) and used that for the suffix. File types without a defined default extension will get .tmp as suffix. Change-Id: If809fef4325e483072c1fa4ee962125d991a197e Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/31065 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_access.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 3de12f070b..5dcca8d2d2 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -2399,6 +2399,8 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
const wtap_dump_params *params, int *err)
{
int fd;
+ const char *ext;
+ char sfx[16];
char *tmpname;
wtap_dumper *wdh;
WFILE_T fh;
@@ -2412,8 +2414,16 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
if (wdh == NULL)
return NULL;
+ /* Choose an appropriate suffix for the file */
+ ext = wtap_default_file_extension(file_type_subtype);
+ if (ext == NULL)
+ ext = "tmp";
+ sfx[0] = '.';
+ sfx[1] = '\0';
+ g_strlcat(sfx, ext, 16);
+
/* Choose a random name for the file */
- fd = create_tempfile(&tmpname, pfx, ".pcapng");
+ fd = create_tempfile(&tmpname, pfx, sfx);
if (fd == -1) {
*err = errno;
g_free(wdh);