diff options
author | midipix <writeonce@midipix.org> | 2024-02-08 02:24:11 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-02-08 03:03:13 +0000 |
commit | dd658df0cf3a5267a148a47191e221fca012eecc (patch) | |
tree | f4a5548842796db9e69b013329f461691809a755 /src/fallback | |
parent | a8ca7c266299e3f52d77d0fc4b82f837b19787a6 (diff) | |
download | slibtool-dd658df0cf3a5267a148a47191e221fca012eecc.tar.bz2 slibtool-dd658df0cf3a5267a148a47191e221fca012eecc.tar.xz |
slbt_archive_import_mri(): avoid tmpnam(), use a tmpfile name pattern instead.
Diffstat (limited to 'src/fallback')
-rw-r--r-- | src/fallback/slbt_archive_import_mri.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/fallback/slbt_archive_import_mri.c b/src/fallback/slbt_archive_import_mri.c index 76fe25d..76a4c06 100644 --- a/src/fallback/slbt_archive_import_mri.c +++ b/src/fallback/slbt_archive_import_mri.c @@ -11,6 +11,8 @@ #include <string.h> #include <stdlib.h> #include <stdbool.h> +#include <inttypes.h> +#include <sys/stat.h> #include <sys/wait.h> #include <slibtool/slibtool.h> @@ -21,12 +23,13 @@ #include "slibtool_readlink_impl.h" #include "slibtool_errinfo_impl.h" +#define PPRIX64 "%"PRIx64 + static char * slbt_mri_argument( int fdat, char * arg, char * buf) { - int i; char * lnk; char * target; char mricwd[PATH_MAX]; @@ -50,10 +53,26 @@ static char * slbt_mri_argument( target = dstbuf; } - for (i=0,lnk=0; i<1024 && !lnk; i++) { - if (!(tmpnam(buf))) + lnk = 0; + + { + struct stat st; + + if (fstatat(fdat,target,&st,0) < 0) return 0; + sprintf(buf, + ".mri.tmplnk" + ".dev."PPRIX64 + ".inode."PPRIX64 + ".size."PPRIX64 + ".tmp", + st.st_dev, + st.st_ino, + st.st_size); + + unlinkat(fdat,buf,0); + if (!(symlinkat(target,fdat,buf))) lnk = buf; } @@ -92,8 +111,8 @@ int slbt_archive_import_mri( char * dst; char * src; char * fmt; - char mridst [L_tmpnam]; - char mrisrc [L_tmpnam]; + char mridst [96]; + char mrisrc [96]; char program[PATH_MAX]; /* fdcwd */ |