Hi Sven,

do you have a small C test case which might show the failure?
It would be a nice addition to uClibc-ng testsuite if it show the
failure.

best regards
 Waldemar

Sven Linker wrote,

> Hi,
> 
> I stumbled upon the following code in tempname.c:
> 
>       switch (kind) {
>           case __GT_NOCREATE:
>               {
>                   struct stat st;
>                   if (stat (tmpl, &st) < 0) {
>                       if (errno == ENOENT) {
>                           fd = 0;
>                           goto restore_and_ret;
>                       } else
>                           /* Give up now. */
>                           return -1;
>                   } else
>                       fd = 0;
>               }
>           case __GT_FILE:
>               fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL | flags,
> mode);
>               break;
> 
> 
> I am baffled by the 'else' branch of the check of 'stat (tmpl, &st) <
> 0'. 
> If I understand the whole thing correctly, this is an error case,
> where 
> a file with the temporary name already exists. But instead, the whole 
> execution falls through to the __GT_FILE branch, and actually opens the
> file.
> 
> If this happens, this file never seems to be closed again (see for
> example
> the usage in tmpnam_r.c:30:
> 
> char * tmpnam_r (char *s)
> {
>     if (s == NULL)
>       return NULL;
> 
>     if (__path_search (s, L_tmpnam, NULL, NULL, 0))
>       return NULL;
>     if (__gen_tempname (s, __GT_NOCREATE, 0, 0, 0))
>       return NULL;
> 
>     return s;
> }
> 
> I would suppose that instead of falling to the next switch-case, we
> should return with a non-zero value (maybe '1' to distinguish it from
> the general error case?).
> 
> Am I missing something basic?
> 
> Cheers,
> Sven
> -- 
> Sven Linker
> Tel.: +49 351 41883243
> Kernkonzept GmbH at Dresden, Germany, 
> HRB 31129, CEO Dr.-Ing. Michael Hohmuth
> 
> 
> _______________________________________________
> devel mailing list -- devel@uclibc-ng.org
> To unsubscribe send an email to devel-le...@uclibc-ng.org
_______________________________________________
devel mailing list -- devel@uclibc-ng.org
To unsubscribe send an email to devel-le...@uclibc-ng.org

Reply via email to