summaryrefslogtreecommitdiff
path: root/src/logic/slbt_exec_install.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-04-13 16:46:12 +0000
committermidipix <writeonce@midipix.org>2021-04-15 08:03:31 +0000
commit7ae5c14d2b4cc2dce023dac9bdf6020962c7bcec (patch)
treed00fe17ad2871f6c8c0090e75653ad23bba963f4 /src/logic/slbt_exec_install.c
parentc2a0f5a12171cbdb1915bad18cf0c48c790a1972 (diff)
downloadslibtool-7ae5c14d2b4cc2dce023dac9bdf6020962c7bcec.tar.bz2
slibtool-7ae5c14d2b4cc2dce023dac9bdf6020962c7bcec.tar.xz
library: replace all uses of stat() and lstat() with fstatat() counterparts.
Diffstat (limited to 'src/logic/slbt_exec_install.c')
-rw-r--r--src/logic/slbt_exec_install.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c
index 4aafd0f..5adfd34 100644
--- a/src/logic/slbt_exec_install.c
+++ b/src/logic/slbt_exec_install.c
@@ -70,12 +70,15 @@ static int slbt_exec_install_init_dstdir(
struct argv_entry * last,
char * dstdir)
{
+ int fdcwd;
struct stat st;
char * slash;
size_t len;
- (void)dctx;
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+ /* last */
if (dest)
last = dest;
@@ -95,7 +98,7 @@ static int slbt_exec_install_init_dstdir(
return 0;
/* is DEST a directory? */
- if (!(stat(dstdir,&st)))
+ if (!fstatat(fdcwd,dstdir,&st,0))
if (S_ISDIR(st.st_mode))
return 0;
@@ -335,6 +338,7 @@ static int slbt_exec_install_entry(
char ** dst)
{
int ret;
+ int fdcwd;
char * dot;
char * base;
char * slash;
@@ -359,10 +363,15 @@ static int slbt_exec_install_entry(
entry->arg) >= sizeof(slnkname))
return SLBT_BUFFER_ERROR(dctx);
- fexe = stat(slnkname,&st)
+ /* fdcwd */
+ fdcwd = slbt_driver_fdcwd(dctx);
+
+ /* fexe */
+ fexe = fstatat(fdcwd,slnkname,&st,0)
? false
: true;
+ /* argument suffix */
dot = strrchr(entry->arg,'.');
/* .lai --> .la */
@@ -389,7 +398,7 @@ static int slbt_exec_install_entry(
srcfile) >= sizeof(slnkname))
return SLBT_BUFFER_ERROR(dctx);
- if (!stat(slnkname,&st)) {
+ if (!fstatat(fdcwd,slnkname,&st,0)) {
if (slbt_readlink(slnkname,target,sizeof(target)) < 0)
return SLBT_SYSTEM_ERROR(dctx,slnkname);
@@ -436,7 +445,7 @@ static int slbt_exec_install_entry(
/* libfoo.a --> libfoo.so.release */
sprintf(dot,"%s.release",dsosuffix);
- frelease = stat(slnkname,&st) ? false : true;
+ frelease = fstatat(fdcwd,slnkname,&st,0) ? false : true;
/* libfoo.a --> libfoo.so */
strcpy(dot,dsosuffix);
@@ -460,7 +469,7 @@ static int slbt_exec_install_entry(
slnkname) >= sizeof(dstfile))
return SLBT_BUFFER_ERROR(dctx);
- fpe = stat(dstfile,&st) ? false : true;
+ fpe = fstatat(fdcwd,dstfile,&st,0) ? false : true;
/* basename */
if ((base = strrchr(slnkname,'/')))
@@ -475,7 +484,7 @@ static int slbt_exec_install_entry(
return 0;
/* -avoid-version? */
- if (stat(slnkname,&st))
+ if (fstatat(fdcwd,slnkname,&st,0))
return SLBT_SYSTEM_ERROR(dctx,slnkname);
/* dstfile */