Mail Archives: djgpp/1994/09/01/09:11:57
Hello DJ,
I've found the 'tmpnam' bug in dj112m1.
My earlier report that this was located in stat() was wrong.
The test program below (+output) shows that findfirst() when
invoked with a non-existent filename sets errno to 18 (ENMFILE),
(No more files) and not to 2 (ENOENT) (No such file or directory).
(Tested on a MS-DOS 6.2 system.)
Adding the patch below (to libsrc\c\gen\mktemp.c) solves the problem.
Regards,
Pieter Kunst (kunst AT prl DOT philips DOT nl)
===============================================================================
*** mktemp.old Sun Aug 28 02:12:58 1994
--- mktemp.c Thu Sep 1 18:17:18 1994
***************
*** 84,90 ****
return(0);
}
else if (stat(path, &sbuf))
! return(errno == ENOENT ? 1 : 0);
/* tricky little algorithm for backward compatibility */
for (trv = start;;) {
--- 84,90 ----
return(0);
}
else if (stat(path, &sbuf))
! return((errno == ENOENT) || (errno == ENMFILE) ? 1 : 0);
/* tricky little algorithm for backward compatibility */
for (trv = start;;) {
===============================================================================
#include <dir.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
int main()
{
char path[100];
struct ffblk ffblk;
int attrib = FA_DIREC | FA_HIDDEN | FA_SYSTEM;
int rv;
strcpy (path, "/nonexist");
printf ("errno (before findfirst()) = %d\n", errno);
rv = findfirst(path, &ffblk, attrib);
printf ("errno (after findfirst()) = %d\n", errno);
printf ("path = %s, rv = %d\n", path, rv);
return 0;
}
===============================================================================
errno (before findfirst()) = 0
errno (after findfirst()) = 18
path = /nonexist, rv = -1
===============================================================================
- Raw text -