with the attached patch, make_random_dir first tries to use $TMPDIR, then $TMP finally defaulting to "/tmp"
-- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur.
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index a9e2a70..3f6a588 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1315,9 +1315,15 @@ static char* make_random_dir(mode_t m) {
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
- char fn[24] = "/tmp/pulse-";
+ const char *system_tmpdir;
+ char *fn;
+ size_t pathlen;
- fn[sizeof(fn)-1] = 0;
+ if ( (system_tmpdir = getenv("TMPDIR")) == NULL )
+ if ( (system_tmpdir = getenv("TMP")) == NULL )
+ system_tmpdir = "/tmp";
+ fn = pa_sprintf_malloc("%s/pulse-XXXXXXXXXXXX", system_tmpdir);
+ pathlen = strlen(fn);
for (;;) {
unsigned i;
@@ -1325,7 +1331,7 @@ static char* make_random_dir(mode_t m) {
mode_t u;
int saved_errno;
- for (i = 11; i < sizeof(fn)-1; i++)
+ for (i = pathlen - 12; i < pathlen; i++)
fn[i] = table[rand() % (sizeof(table)-1)];
u = umask((~m) & 0777);
@@ -1334,7 +1340,7 @@ static char* make_random_dir(mode_t m) {
umask(u);
if (r >= 0)
- return pa_xstrdup(fn);
+ return fn;
errno = saved_errno;
signature.asc
Description: This is a digitally signed message part
_______________________________________________ pulseaudio-discuss mailing list [email protected] https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
