From 7c414b2d849fd16a0c987d4c9d33db9eee0a610d Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 23 Mar 2026 08:44:01 +0000 Subject: 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 --- util/nvmutil/lib/file.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'util/nvmutil/lib/file.c') diff --git a/util/nvmutil/lib/file.c b/util/nvmutil/lib/file.c index 30694623..a0313405 100644 --- a/util/nvmutil/lib/file.c +++ b/util/nvmutil/lib/file.c @@ -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; -- cgit v1.2.1