mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
util/nvmutil: use portable mkstemp
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+17
-2
@@ -466,6 +466,7 @@ static const char *getnvmprogname(void);
|
|||||||
* a special kind of hell
|
* a special kind of hell
|
||||||
*/
|
*/
|
||||||
static char *new_tmpfile(int *fd, int local, const char *path);
|
static char *new_tmpfile(int *fd, int local, const char *path);
|
||||||
|
static int x_i_mkstemp(char *template);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sizes in bytes:
|
* Sizes in bytes:
|
||||||
@@ -693,7 +694,6 @@ static ino_t tmp_ino;
|
|||||||
* prototypes. Should be safe
|
* prototypes. Should be safe
|
||||||
* on most Unices and compilers
|
* on most Unices and compilers
|
||||||
*/
|
*/
|
||||||
int mkstemp(char *template);
|
|
||||||
int fchmod(int fd, mode_t mode);
|
int fchmod(int fd, mode_t mode);
|
||||||
|
|
||||||
static int tmp_fd = -1;
|
static int tmp_fd = -1;
|
||||||
@@ -2910,7 +2910,7 @@ new_tmpfile(int *fd, int local, const char *path)
|
|||||||
|
|
||||||
dest[tmppath_len] = '\0';
|
dest[tmppath_len] = '\0';
|
||||||
|
|
||||||
fd_tmp = mkstemp(dest);
|
fd_tmp = x_i_mkstemp(dest);
|
||||||
if (fd_tmp == -1)
|
if (fd_tmp == -1)
|
||||||
goto err_new_tmpfile;
|
goto err_new_tmpfile;
|
||||||
|
|
||||||
@@ -2975,3 +2975,18 @@ err_new_tmpfile:
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* portable mkstemp
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
x_i_mkstemp(char *template)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (mktemp(template) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user