diff options
author | Michael Mann <mmann78@netscape.net> | 2019-09-01 14:37:38 -0400 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2019-12-20 19:26:38 +0000 |
commit | 2925fb0850ee3ab005dd02d69994390827c2e008 (patch) | |
tree | 94813abb14d09312998be4ac497302fb32ddb7f7 /dumpcap.c | |
parent | c247a8351f4d2be224e8cc424e104d8823450f5d (diff) |
Use g_file_open_tmp within create_tempfile
Much better to use a known library than create it ourselves.
Also remove get_tempfile_path as it's not used.
Bug: 15992
Change-Id: I17b9bd879e8bdb540f79db83c6c138f8ee724764
Reviewed-on: https://code.wireshark.org/review/34420
Reviewed-by: Tomasz Moń <desowin@gmail.com>
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'dumpcap.c')
-rw-r--r-- | dumpcap.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -3428,10 +3428,10 @@ static gboolean capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, char *errmsg, int errmsg_len) { - char *tmpname; gchar *capfile_name; gchar *prefix, *suffix; gboolean is_tempfile; + GError *err_tempfile = NULL; g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "capture_loop_open_output: %s", (capture_opts->save_file) ? capture_opts->save_file : "(not specified)"); @@ -3556,9 +3556,8 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, } else { suffix = ".pcap"; } - *save_file_fd = create_tempfile(&tmpname, prefix, suffix); + *save_file_fd = create_tempfile(&capfile_name, prefix, suffix, &err_tempfile); g_free(prefix); - capfile_name = g_strdup(tmpname); is_tempfile = TRUE; } @@ -3567,7 +3566,8 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, if (is_tempfile) { g_snprintf(errmsg, errmsg_len, "The temporary file to which the capture would be saved (\"%s\") " - "could not be opened: %s.", capfile_name, g_strerror(errno)); + "could not be opened: %s.", capfile_name, err_tempfile->message); + g_error_free(err_tempfile); } else { if (capture_opts->multi_files_on) { /* Ensures that the ringbuffer is not used. This ensures that |