Hi Sven,
thanks, applied and pushed.
best regards Waldemar
Sven Linker wrote,
Hi Waldemar,
sure, please find the patch attached.
Cheers, Sven
On Sun, 2024-02-11 at 07:04 +0100, Waldemar Brodkorb wrote:
Hi Sven,
okay. Can you resent the patch with git format-patch -s origin? Please add a commit message.
Thanks a lot in advance. Waldemar
Sven Linker wrote,
Hi,
I'm not sure if this really tests the branch where the issue is, but I am also not able to come up with a simple test myself (since it basically relies on predicting the random instantiation of the template).
But this patch should avoid opening the file, if it already exists.
Cheers, Sven
On Tue, 2024-02-06 at 15:13 +0100, Marius Melzer wrote:
Hi,
On 31.01.24 11:08, Waldemar Brodkorb wrote:
do you have a small C test case which might show the failure?
I unfortunately currently don't have a proper setup to test this, but I would expect that this simple loop would deplete all available file descriptors so that at some point, one can't call "open" anymore:
#include <stdlib.h>
do { puts("Still fds available\n"); } while(!strcmp(mktemp("test"),""))
if(open("somefile.txt") < 0) { puts("fds are depleted. This should not have happened.\n"); }
Best regards, Marius
-- Sven Linker Tel.: +49 351 41883243 Kernkonzept GmbH at Dresden, Germany, HRB 31129, CEO Dr.-Ing. Michael Hohmuth
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c index d3a8ccbd8..f9b714a68 100644 --- a/libc/misc/internals/tempname.c +++ b/libc/misc/internals/tempname.c @@ -218,7 +218,8 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind, int flags, /* Give up now. */ return -1; } else
fd = 0;
/* File already exists, so return with
non-zero value */
return -1;
} case __GT_FILE: fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL | flags, mode);
devel mailing list -- devel@uclibc-ng.org To unsubscribe send an email to devel-leave@uclibc-ng.org
-- Sven Linker Tel.: +49 351 41883243 Kernkonzept GmbH at Dresden, Germany, HRB 31129, CEO Dr.-Ing. Michael Hohmuth
From fb56d9874751c51f493a3ce63080c8c320ef614a Mon Sep 17 00:00:00 2001 From: Sven Linker sven.linker@kernkonzept.com Date: Wed, 7 Feb 2024 10:27:58 +0100 Subject: [PATCH] Avoid fall-through if file matching temporary name exists
During checking whether a temporary name can be created, it may happen that a file with this name already exists. Avoid falling through to opening the file name in this case, and return with an error instead.
Signed-off-by: Sven Linker sven.linker@kernkonzept.com
libc/misc/internals/tempname.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c index d3a8ccbd8..f9b714a68 100644 --- a/libc/misc/internals/tempname.c +++ b/libc/misc/internals/tempname.c @@ -218,7 +218,8 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind, int flags, /* Give up now. */ return -1; } else
fd = 0;
/* File already exists, so return with non-zero value */
} case __GT_FILE: fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL | flags, mode);return -1;
-- 2.43.0
devel mailing list -- devel@uclibc-ng.org To unsubscribe send an email to devel-leave@uclibc-ng.org