diff options
author | midipix <writeonce@midipix.org> | 2021-04-15 10:06:44 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-04-15 13:26:15 +0000 |
commit | cc0827cebd811eab83d091ffde3780e5c0084160 (patch) | |
tree | 87209192602b7a0f61d774632e03339c9bffe9a7 /src/internal/slibtool_symlink_impl.c | |
parent | 1ce3d5d23f5c66c8223b5567f0d7d5b630e819e1 (diff) | |
download | slibtool-cc0827cebd811eab83d091ffde3780e5c0084160.tar.bz2 slibtool-cc0827cebd811eab83d091ffde3780e5c0084160.tar.xz |
internals: slbt_create_symlink(): properly handle absolute-path link targets.
Diffstat (limited to 'src/internal/slibtool_symlink_impl.c')
-rw-r--r-- | src/internal/slibtool_symlink_impl.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c index ca7f6cd..0b1daa0 100644 --- a/src/internal/slibtool_symlink_impl.c +++ b/src/internal/slibtool_symlink_impl.c @@ -23,9 +23,11 @@ int slbt_create_symlink( struct slbt_exec_ctx * ectx, const char * target, const char * lnkname, - bool flawrapper) + uint32_t options) { int fdcwd; + int fliteral; + int fwrapper; char ** oargv; const char * slash; char * ln[5]; @@ -36,12 +38,20 @@ int slbt_create_symlink( char atarget[PATH_MAX]; char * suffix = 0; + /* options */ + fliteral = (options & SLBT_SYMLINK_LITERAL); + fwrapper = (options & SLBT_SYMLINK_WRAPPER); + /* symlink is a placeholder? */ if ((dctx->cctx->drvflags & SLBT_DEV_NULL_FLAGS) && !strcmp(target,"/dev/null")) { slash = target; suffix = ".disabled"; + /* target is an absolute path? */ + } else if (fliteral) { + slash = target; + /* symlink target contains a dirname? */ } else if ((slash = strrchr(target,'/'))) { slash++; @@ -52,7 +62,7 @@ int slbt_create_symlink( } /* .la wrapper? */ - dotdot = flawrapper ? "../" : ""; + dotdot = fwrapper ? "../" : ""; /* atarget */ if ((size_t)snprintf(atarget,sizeof(atarget),"%s%s", |