Index: src/compat_fs.c =================================================================== --- src/compat_fs.c (revision 27837) +++ src/compat_fs.c (revision 27838) @@ -50,6 +50,7 @@ #include "compat_misc.h" #include "globalconst.h" #include "safe_fs.h" +#include "hid_init.h" #include @@ -149,6 +150,22 @@ char *pcb_tempfile_name_new(const char *name) { char *tmpfile = NULL; + +#ifdef __WIN32__ + const char *tmpdir; + char *res, *c, num[256]; + unsigned int r1 = rand(), r2 = rand(); /* weaker fallback */ + + rand_s(&r1); rand_s(&r2); /* crypto secure according to the API doc */ + + sprintf(num, "%lu%lu", r1, r2); + tmpdir = pcb_w32_cachedir; + res = pcb_concat(tmpdir, "/", num, NULL); + for(c = res; *c; c++) + if (*c == '\\') + *c = '/'; + return res; +#else #ifdef HAVE_MKDTEMP #ifdef inline /* Suppress compiler warnings; -Dinline means we are compiling in @@ -212,18 +229,9 @@ * in case someone decides to create multiple temp names. */ tmpfile = pcb_strdup(tmpnam(NULL)); -#ifdef __WIN32__ - { - /* Guile doesn't like \ separators */ - char *c; - for (c = tmpfile; *c; c++) - if (*c == '\\') - *c = '/'; - } #endif + return tmpfile; #endif - - return tmpfile; } /* If we have mkdtemp() then our temp file lives in a temporary directory and