misc: use everywhere mkstemp_cloexec() as fallback to mkostemp()
The function mkostemp() does not have to be available everywhere, and for this reason, we have mkstemp_cloexec() as a fallback solution. Unfortunately, some codes (usually fuzzy tests) do not use the fallback. Let's fix it. Signed-off-by: Karel Zak <kzak@redhat.com>pull/1599/head
parent
55bcc40952
commit
adcd2c322c
|
@ -4,6 +4,7 @@
|
|||
#include "carefulputc.h"
|
||||
#include "mangle.h"
|
||||
#include "jsonwrt.h"
|
||||
#include "fileutils.h"
|
||||
|
||||
#ifdef FUZZ_TARGET
|
||||
#include "fuzz.h"
|
||||
|
@ -1574,9 +1575,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||
struct fdisk_context *cxt;
|
||||
FILE *f;
|
||||
|
||||
fd = mkostemp(name, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
|
||||
fd = mkstemp_cloexec(name);
|
||||
if (fd < 0)
|
||||
err(EXIT_FAILURE, "mkostemp() failed");
|
||||
err(EXIT_FAILURE, "mkstemp() failed");
|
||||
if (write_all(fd, data, size) != 0)
|
||||
err(EXIT_FAILURE, "write() failed");
|
||||
f = fopen(name, "r");
|
||||
|
|
|
@ -890,7 +890,8 @@ int mnt_open_uniq_filename(const char *filename, char **name)
|
|||
*/
|
||||
oldmode = umask(S_IRGRP|S_IWGRP|S_IXGRP|
|
||||
S_IROTH|S_IWOTH|S_IXOTH);
|
||||
fd = mkostemp(n, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
|
||||
|
||||
fd = mkstemp_cloexec(n);
|
||||
if (fd < 0)
|
||||
fd = -errno;
|
||||
umask(oldmode);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "strutils.h"
|
||||
#include "timeutils.h"
|
||||
#include "monotonic.h"
|
||||
#include "fileutils.h"
|
||||
|
||||
#ifdef FUZZ_TARGET
|
||||
#include "fuzz.h"
|
||||
|
@ -939,9 +940,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||
char name[] = "/tmp/test-last-fuzz.XXXXXX";
|
||||
int fd;
|
||||
|
||||
fd = mkostemp(name, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
|
||||
fd = mkstemp_cloexec(name);
|
||||
if (fd < 0)
|
||||
err(EXIT_FAILURE, "mkostemp() failed");
|
||||
err(EXIT_FAILURE, "mkstemp() failed");
|
||||
if (write_all(fd, data, size) != 0)
|
||||
err(EXIT_FAILURE, "write() failed");
|
||||
|
||||
|
|
Loading…
Reference in New Issue