Message ID | f9daaf58e8a0698f522a76166f59348030cbd1bc.camel@kernkonzept.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [uclibc-ng-devel] Re: Possible bug in tempname.c (and its usage)? | expand |
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
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);