safer macro

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-04-01 06:10:57 +01:00
parent e731893208
commit f90af15502
2 changed files with 12 additions and 6 deletions
+8 -6
View File
@@ -826,12 +826,14 @@ close_on_eintr(int *fd)
* ONE MACRO TO RULE THEM ALL: * ONE MACRO TO RULE THEM ALL:
*/ */
#define fs_err_retry() \ #define fs_err_retry() \
if ((rval == -1) && \ do { \
(errno == EINTR)) \ if ((rval == -1) && \
return 1; \ (errno == EINTR)) \
if (rval >= 0 && !errno) \ return 1; \
errno = saved_errno; \ if (rval >= 0 && !errno) \
return 0 errno = saved_errno; \
return 0; \
} while(0)
/* /*
* Regarding the errno logic above: * Regarding the errno logic above:
* on success, it is permitted that * on success, it is permitted that
+4
View File
@@ -699,6 +699,10 @@ mkhtemp_tmpfile_linux(int dirfd,
linked = 1; /* file created */ linked = 1; /* file created */
/* TODO: potential fd leak here.
* probably should only set *fd on successful
* return from this function (see below)
*/
if (fd_verify_dir_identity(dirfd, st_dir_first) < 0 || if (fd_verify_dir_identity(dirfd, st_dir_first) < 0 ||
fstat(*fd = tmpfd, st) < 0 || fstat(*fd = tmpfd, st) < 0 ||
secure_file(fd, st, st, O_APPEND, 1, 1, 0600) < 0) secure_file(fd, st, st, O_APPEND, 1, 1, 0600) < 0)