diff options
-rw-r--r-- | COPYING.SOFORT | 2 | ||||
-rw-r--r-- | sofort/cfgtest/cfgtest.sh | 2 | ||||
-rw-r--r-- | src/internal/tpax_tmpfile_impl.c | 22 |
3 files changed, 19 insertions, 7 deletions
diff --git a/COPYING.SOFORT b/COPYING.SOFORT index 75a98e1..1c8a6c1 100644 --- a/COPYING.SOFORT +++ b/COPYING.SOFORT @@ -2,7 +2,7 @@ /* */ /* sofort: portable software project skeleton */ /* */ -/* Copyright (C) 2015--2023 SysDeer Technologies, LLC */ +/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */ /* */ /* sofort provides a build system that can be incorporated into Works */ /* which may or may not be covered by a copyleft license. THE FOLLOWING */ diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh index 8e1db07..7bb27a0 100644 --- a/sofort/cfgtest/cfgtest.sh +++ b/sofort/cfgtest/cfgtest.sh @@ -423,7 +423,7 @@ cfgtest_interface_presence() # init cfgtest_prolog 'interface' "${1}" - cfgtest_code_snippet=$(printf 'void * addr = &%s;\n' "${1}") + cfgtest_code_snippet=$(printf 'void (*addr)() = (void (*)())&%s;\n' "${1}") cfgtest_common_init diff --git a/src/internal/tpax_tmpfile_impl.c b/src/internal/tpax_tmpfile_impl.c index 56d5c92..9dd9d40 100644 --- a/src/internal/tpax_tmpfile_impl.c +++ b/src/internal/tpax_tmpfile_impl.c @@ -5,12 +5,16 @@ /**************************************************************/ #define _GNU_SOURCE +#include <time.h> #include <fcntl.h> #include <limits.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> +#include <inttypes.h> + +#define PPRIX64 "%"PRIx64 /* mkostemp might be guarded by non-standard macros */ /* unless HAVE_NO_MKOSTEMP, assume it is available */ @@ -54,8 +58,8 @@ static int tpax_mkostemp(char * tmplate) int tpax_tmpfile(void) { int fd; - unsigned seed; - char tmplate[64]; + void * addr; + char tmplate[128]; /* try with __fs_tmpfile() */ if ((fd = tpax_tmpfile_by_framework()) >= 0) @@ -66,10 +70,18 @@ int tpax_tmpfile(void) return fd; /* fallback to mk{o}stemp */ - seed = getpid(); + addr = tmplate; memset(tmplate,0,sizeof(tmplate)); - snprintf(tmplate,sizeof(tmplate),"/tmp/tpax_%d_%d_%d_XXXXXXXXXXXX", - getppid(),getpid(),rand_r(&seed)); + snprintf(tmplate,sizeof(tmplate), + "/tmp/" + ".tpax.tmpfile" + ".time."PPRIX64 + ".salt.%p" + ".pid.%d" + ".XXXXXXXXXXXX", + time(0), + addr, + getpid()); return tpax_mkostemp(tmplate); } |