tmpnam() in OgreDeflate.cpp woes under Windows

Problems building or running the engine, queries about how to use features etc.
Post Reply
FireMartZ
Gnoblar
Posts: 2
Joined: Tue May 29, 2012 4:43 pm

tmpnam() in OgreDeflate.cpp woes under Windows

Post by FireMartZ »

I noticed a problem running the Terrain sample under Windows 7, when code is on C: drive (in a sub-directory of course) and UAC are enabled. I traced it down to tmpnam() in OgreDeflate.cpp that is generating a filename starting with a backslash.

From Microsoft documentation:
Note than when a file name is pre-pended with a backslash and no path information, such as \fname21, this indicates that the name is valid for the current working directory.
Currently, the generated name is used as-is and thus the effect is that it tries to create a file on the root of the current drive and since UAC won't allow a file to be created on c:\, it silently fails and crash not long after.

A quick fix that first appear to me as compatible with other platforms would be to check if the filename starts with a backslash ('\\') and either prepend a dot ('.') or skip the backslash when assigning mTempFileName:

Code: Select all

if (tmpname[0] == '\\')
    mTempFileName = &tmpname[1];
else
    mTempFileName = tmpname;
But a safe fix would be probably to enclose that part in #define for the Win32 platform.

From what I've read somewhere, tmpnam() would generate a complete valid temporary filename on linux, such as '/tmp/ta22.1'.

What do you think?

Edit: typos
FireMartZ
Gnoblar
Posts: 2
Joined: Tue May 29, 2012 4:43 pm

Re: tmpnam() in OgreDeflate.cpp woes under Windows

Post by FireMartZ »

Anyone?

Maybe this should be moved in the papercuts forum?
User avatar
arcanemartz
Gnoblar
Posts: 6
Joined: Tue Jun 26, 2012 11:38 pm
x 3
Contact:

Re: tmpnam() in OgreDeflate.cpp woes under Windows

Post by arcanemartz »

In case some other have encountered the problem, I posted a patch on the bug tracker about that problem:

http://sourceforge.net/tracker/?func=de ... tid=302997
Post Reply