mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 13:29:03 +02:00
mkhtemp: fix bad close
the fd in fs_resolve_at is subsequently used note that in practise, this is not a real fix: the best fix is to cache all descriptors and free them at the end, once resolution is done. not a real fix, because now fd leaks, but it's dealt with on program close. not a util yet. just just stubbing this in main to test various features. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -2032,9 +2032,34 @@ fs_resolve_at(int dirfd, const char *path, int flags)
|
||||
if (nextfd < 0)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
don't close fd.
|
||||
it's used next by a few functions.
|
||||
this results in a fd leak, but
|
||||
makes the code work:
|
||||
in practise, your program
|
||||
will free all descriptors
|
||||
on exit
|
||||
|
||||
what we need to do is figure out a proper
|
||||
system of storing descriptors,
|
||||
and freeing them when it's safe;
|
||||
see how this function is called
|
||||
and whatt calls those and you see what i mean
|
||||
|
||||
who owns what is currently not consistent.
|
||||
needs rework.
|
||||
|
||||
this will be fixed at a later date.
|
||||
justt leaving thtis in here for future me.
|
||||
|
||||
with this uncommented, i always just get
|
||||
"Bad file descriptor" error:
|
||||
|
||||
saved_close_errno = errno;
|
||||
(void) close_on_eintr(dirfd);
|
||||
errno = saved_close_errno;
|
||||
*/
|
||||
|
||||
dirfd = nextfd;
|
||||
nextfd = -1;
|
||||
|
||||
@@ -35,6 +35,16 @@ main(int argc, char *argv[])
|
||||
|
||||
size_t c;
|
||||
|
||||
int rval;
|
||||
char *test = NULL;
|
||||
int fd = -1;
|
||||
rval = new_tmpfile(&fd, &test);
|
||||
if (rval < 0)
|
||||
err_no_cleanup(errno, "TESTERR: ");
|
||||
|
||||
printf("TEST: %s", test);
|
||||
exit(1);
|
||||
|
||||
/* https://man.openbsd.org/pledge.2
|
||||
https://man.openbsd.org/unveil.2 */
|
||||
#if defined(__OpenBSD__) && defined(OpenBSD)
|
||||
|
||||
Reference in New Issue
Block a user