diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-16 15:15:53 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-16 15:15:53 +0000 |
| commit | 4ecce163d601a4df007bc48ed0b9f2f11b3cfc47 (patch) | |
| tree | 766877a806b5dc7e5d0cce64ed971d69ca31dd1f /util/nvmutil/nvmutil.c | |
| parent | 68ef78e439d9d15cab5b8f3a698b8770a60b7af7 (diff) | |
util/nvmutil: use portable mkstemp
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 4d7c7dbb..12a6cf5a 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -466,6 +466,7 @@ static const char *getnvmprogname(void); * a special kind of hell */ static char *new_tmpfile(int *fd, int local, const char *path); +static int x_i_mkstemp(char *template); /* * Sizes in bytes: @@ -693,7 +694,6 @@ static ino_t tmp_ino; * prototypes. Should be safe * on most Unices and compilers */ -int mkstemp(char *template); int fchmod(int fd, mode_t mode); static int tmp_fd = -1; @@ -2910,7 +2910,7 @@ new_tmpfile(int *fd, int local, const char *path) dest[tmppath_len] = '\0'; - fd_tmp = mkstemp(dest); + fd_tmp = x_i_mkstemp(dest); if (fd_tmp == -1) goto err_new_tmpfile; @@ -2975,3 +2975,18 @@ err_new_tmpfile: 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; +} |
