On 2008-08-15 Clint Adams <[EMAIL PROTECTED]> wrote:
> Possible solutions:

> 1) change the algorithm
> 2) use libc mkstemp (will break templates shorter than 6 characters)
> 3) ship mktemp from sarge (will break templates shorter than 6
> characters)
> 4) ship coreutils mktemp (will break templates shorter than 3
> characters)

Hello,

is there actually a reason for using the PID and for limiting the
non-pid part to [[A-Za-z]?

Why not
--------bugs included-----
--- mktemp-1.5.orig/priv_mktemp.c
+++ mktemp-1.5/priv_mktemp.c
@@ -81,25 +81,20 @@
        register char *start, *trv;
        struct stat sbuf;
        int pid, rval;
-       char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+       char *alphabet = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-=%#_";
 
        if (doopen && domkdir) {
                errno = EINVAL;
                return(0);
        }
 
-       pid = getpid();
        for (trv = path; *trv; ++trv)
                ;
        --trv;
-       while (trv >= path && *trv == 'X' && pid != 0) {
-               *trv-- = (pid % 10) + '0';
-               pid /= 10;
-       }
        while (trv >= path && *trv == 'X') {
                char c;
 
-               pid = (get_random() & 0xffff) % (26+26);
+               pid = (get_random() & 0xffff) % (26+26+10+6);
                c = alphabet[pid];
                *trv-- = c;
        }
-------------------------
cu andreas
-- 
`What a good friend you are to him, Dr. Maturin. His other friends are
so grateful to you.'
`I sew his ears on from time to time, sure'



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to