aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_access.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2019-09-01 14:37:38 -0400
committerRoland Knall <rknall@gmail.com>2019-12-20 19:26:38 +0000
commit2925fb0850ee3ab005dd02d69994390827c2e008 (patch)
tree94813abb14d09312998be4ac497302fb32ddb7f7 /wiretap/file_access.c
parentc247a8351f4d2be224e8cc424e104d8823450f5d (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 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 6782933858..ee8da291bf 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -2422,7 +2422,6 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
int fd;
const char *ext;
char sfx[16];
- char *tmpname;
wtap_dumper *wdh;
WFILE_T fh;
@@ -2444,13 +2443,12 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
g_strlcat(sfx, ext, 16);
/* Choose a random name for the file */
- fd = create_tempfile(&tmpname, pfx, sfx);
+ fd = create_tempfile(filenamep, pfx, sfx, NULL);
if (fd == -1) {
- *err = errno;
+ *err = WTAP_ERR_CANT_OPEN;
g_free(wdh);
return NULL; /* can't create file */
}
- *filenamep = g_strdup(tmpname);
/* In case "fopen()" fails but doesn't set "errno", set "errno"
to a generic "the open failed" error. */
@@ -2468,7 +2466,7 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
/* Get rid of the file we created; we couldn't finish
opening it. */
wtap_dump_file_close(wdh);
- ws_unlink(tmpname);
+ ws_unlink(*filenamep);
g_free(wdh);
return NULL;
}