This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B20.1: bug in mkstemp


mkstemp fails with an access errror when an attempt is made to create more than one file using the same mkstemp template. This problem was reported previously by Rob Mayoff.
 
In Rob's original report, he gives the following program that demonstrates the problem:
 
In this program, the second call to mkstemp will fail:
 
#include <stdio.h>
#include <sys/param.h>
 
main()
{
  char path[MAXPATHLEN];
        int fd, rc;
 
        sprintf(path, "/tmp/test.XXXXXX");
        fd = mkstemp(path);
        if (fd < 0) { perror("mkstemp 1"); exit(1); }
        rc = unlink(path);
        if (rc < 0) { perror("unlink"); exit(1); }
        sprintf(path, "/tmp/test.XXXXXX");
        fd = mkstemp(path);
        if (fd < 0) { perror("mkstemp 2"); exit(1); }
        rc = unlink(path);
        if (rc < 0) { perror("unlink"); exit(1); }
 
        exit(0);
}
 
The fix should be simply to treat EACCES just like EEXIST in mkstemp.
 
I have applied a patch to the runtime source file, mktemp.c, as Rob suggests and
verified the fix. I include the patch as an attachment.
 
John
 
John Poplett
jpoplett@mindspring.com

mktemp.c

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]