Hello Nigel,

Thursday, March 3, 2005, 10:06:43 PM, you wrote:

NH> On Thursday 03 Mar 2005 09:56, -=MikeP=- wrote:
   
>> +#ifdef C_QNX6
>> +       snprintf(fullname, sizeof(fullname), "%s/clamavtmpXXXXXXXXXXXXX", 
>> dir);

NH> Is that right? QNX's mkstemp takes 13Xs not the standard 6?

>> +#else
>>         snprintf(fullname, sizeof(fullname) - 1 - suffixLen, 
>> "%s/%.*sXXXXXX", dir,
>>                 (int)(sizeof(fullname) - 9 - suffixLen - strlen(dir)), 
>> filename);
>> +#endif


NH> -Nigel


mkstemp() can take any number of X-es - the more X-es -- the better
filenames differ from each other. Docs say the following:

--- cut ---
The mkstemp() function takes the given file name template and
overwrites a portion of it to create a filename. This file name is
unique and suitable for use by the application. The trailing Xs are
replaced with the current process number and/or a unique letter
combination. The number of unique file names mkstemp() can return
depends on the number of Xs provided; if you specify six Xs, mkstemp()
tests roughly 26^6 combinations.
--- cut ---

This behavior is XOPEN - compliant (IEEE POSIX Std. 1003.1-2001)

I know that implementations in different platforms differ. As in
NetBSD - this function will take any number of X-es but for
portability reasons they recommend six.

But this patch does not affect other OS-es that may be serious about
the number of X-es... So I don't mind if the number of X-es is reduced
but frankly speaking I don't see the need for naming temporary files
using the name(or part of it) of the source file. Besides using the
name in form dir/clamavtmpXXXXXXXXXXXXX let me avoid sanitizing the
filename and exceeding the maximum file name length.



-- 
Best regards,
 -=MikeP=-                            mailto:[EMAIL PROTECTED]

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html

Reply via email to