diff options
author | portix <portix@gmx.net> | 2014-02-24 21:36:56 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2014-02-24 21:36:56 +0100 |
commit | 18c3d8eb49cba7b1d25d79092134393a23053537 (patch) | |
tree | c4cfaeef432d0016a8bd01dbfa01d4eec8051298 | |
parent | 02fa54e7926b6f8712e21db7483bed7d6696d2fc (diff) | |
download | dwb-18c3d8eb49cba7b1d25d79092134393a23053537.zip |
Use mkstemp instead of mktemp
-rw-r--r-- | exar/exar.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/exar/exar.c b/exar/exar.c index 43af1790..298c0631 100644 --- a/exar/exar.c +++ b/exar/exar.c @@ -19,6 +19,9 @@ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 1 +#endif #include <stdlib.h> #include <string.h> @@ -579,19 +582,20 @@ exar_delete(const char *archive, const char *file) unsigned char rbuf; size_t dir_length = 0; int status = EE_ERROR; + int fd; if ((f = open_archive(archive, "r")) == NULL) goto finish; snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", archive); - if (mktemp(tmp_file) == NULL) + if ((fd = mkstemp(tmp_file)) == -1) { - fprintf(stderr, "Failed to create temporary file\n"); + perror("mktemp"); goto finish; } LOG(3, "Opening %s for writing\n", tmp_file); - if ((ftmp = fopen(tmp_file, "w")) == NULL) + if ((ftmp = fdopen(fd, "w")) == NULL) goto finish; while ((status = get_file_header(f, &header)) == EE_OK) |