diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-01 06:10:57 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-01 06:10:57 +0100 |
| commit | f90af15502dbcd4c3fb8df66b77f869d005978cd (patch) | |
| tree | 561503e1d5380ba7409401d8346d52fe7893f038 | |
| parent | e731893208cd6e2401a2171672e6928b05947e3f (diff) | |
safer macro
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/libreboot-utils/lib/file.c | 14 | ||||
| -rw-r--r-- | util/libreboot-utils/lib/mkhtemp.c | 4 |
2 files changed, 12 insertions, 6 deletions
diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c index 805db726..12f52c56 100644 --- a/util/libreboot-utils/lib/file.c +++ b/util/libreboot-utils/lib/file.c @@ -826,12 +826,14 @@ close_on_eintr(int *fd) * ONE MACRO TO RULE THEM ALL: */ #define fs_err_retry() \ - if ((rval == -1) && \ - (errno == EINTR)) \ - return 1; \ - if (rval >= 0 && !errno) \ - errno = saved_errno; \ - return 0 + do { \ + if ((rval == -1) && \ + (errno == EINTR)) \ + return 1; \ + if (rval >= 0 && !errno) \ + errno = saved_errno; \ + return 0; \ + } while(0) /* * Regarding the errno logic above: * on success, it is permitted that diff --git a/util/libreboot-utils/lib/mkhtemp.c b/util/libreboot-utils/lib/mkhtemp.c index c1574634..7d1a02f3 100644 --- a/util/libreboot-utils/lib/mkhtemp.c +++ b/util/libreboot-utils/lib/mkhtemp.c @@ -699,6 +699,10 @@ mkhtemp_tmpfile_linux(int dirfd, 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 || fstat(*fd = tmpfd, st) < 0 || secure_file(fd, st, st, O_APPEND, 1, 1, 0600) < 0) |
