[Mono-dev] [PATCH] MS.NET compatible Path.GetTempFileName
Robert Jordan
robertj at gmx.net
Fri Jan 6 18:45:12 EST 2006
Kornél,
> Hi,
>
>> How about just appending ".tmp" to the temp file name while
>> still using ints for the pattern?
>
>
> I don't insist on 16-bit numbers if you (other people) belive that 16-bits
> are few and we need 32-bits I will accept it.
>
> But if we want to provide the same behavior as MS.NET we have to use 16-bit
> numbers. When I created the test case (attached to my previous message) and
> runned it I realized that is't quite unlikely to have 65536 temp files at
> the same time and in fact the global (system scoped) counter that is
> used by
> GetTempFileName (Win32) is very unlikely to overflow (go back to 0 in this
> case) altough the same counter is used regardless of file name prefix. If
> someone wants to disable GetTempFileName by creating all possible file
> names
> he can do with any arbitary count of bits as well.
>
> I don't know whether anyone relies on the fact that counter is 16-bit only
> but I think 16-bit is enough to count temporary files and in addition we
> can
> provide an MS.NET compatible file naming pattern.
>
> Note that Ben pointed out (in a private e-mail) that MS.NET 2.0 has a more
> specific documentation that MS.NET 1.1:
> http://msdn2.microsoft.com/en-us/library/system.io.path.gettempfilename.aspx
I don't agree. Unix is not Win32. Under Unix the temp directory is
usually shared, so you have only one "namespace" for the temp files
per system. Allowing just 2^16 temp files per system can lead to a DoS,
while using 2^32 usually cannot, because non-privileged user accounts
use to have a quota that doesn't allow the creation of 2^32 files.
So either we include the user name in the temp file pattern as well,
or we allow 2^32 files.
Robert
More information about the Mono-devel-list
mailing list