[Bug 17875] New: GetTempFileName with unique != 0 broken

wine-bugs at winehq.org wine-bugs at winehq.org
Sat Mar 28 12:07:51 CDT 2009


           Summary: GetTempFileName with unique != 0 broken
           Product: Wine
           Version: 1.1.18
          Platform: PC-x86-64
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: major
          Priority: P1
         Component: kernel32
        AssignedTo: wine-bugs at winehq.org
        ReportedBy: dev_oskar at hotmail.com

GetTempFileName called with a non-zero value for unique will not check if a
file could be actually written in the provided path. 

Paint Shop Pro 9 (and it seems 8 too) uses the return code to test if it should
create several temp directories. So under wine it will always fail if unique is
non-zero, GetTempFileName will currently not test anything and won't return
zero, so creation of the undo files later will fail because the directory
doesn't exists.

As the documentation tells the file isn't created my first patch isn't correct:

    if (unique) {
        sprintfW( p, formatW, unique );
        /* need to check if we can create the file so applications can detect
if they can write */
        HANDLE handle;
        handle = CreateFileW( buffer, GENERIC_WRITE, 0, NULL,
                              CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
        if (handle != INVALID_HANDLE_VALUE)
        {  /* We created it */
           CloseHandle( handle );
           TRACE("created %s\n", debugstr_w(buffer) );
           return unique; 
        /* Failure */
        return 0;
        /* get a "random" unique number and try to create the file */

It should check the directory if it exists.

Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.

More information about the wine-bugs mailing list