From ca36f56b368ece9c0f3b276a456e5c5a7ce3c151 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 10 Nov 2018 17:06:29 -0500 Subject: install mode: host flavors: properly support suffixed suffixes. --- src/logic/slbt_exec_install.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c index 9665dd4..0ab33a5 100644 --- a/src/logic/slbt_exec_install.c +++ b/src/logic/slbt_exec_install.c @@ -328,6 +328,7 @@ static int slbt_exec_install_entry( char * dot; char * base; char * slash; + char * suffix; char target [PATH_MAX]; char srcfile [PATH_MAX]; char dstfile [PATH_MAX]; @@ -489,19 +490,38 @@ static int slbt_exec_install_entry( if (frelease) return 0; - /* libfoo.so.x.y.z --> libfoo.so.x */ + /* libfoo.so.x --> libfoo.so.x.y.z */ strcpy(slnkname,target); - if ((dot = strrchr(slnkname,'.'))) - *dot = 0; + if ((suffix = strrchr(slnkname,'.'))) + *suffix++ = 0; else return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); if ((dot = strrchr(slnkname,'.'))) - *dot = 0; + *dot++ = 0; else return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); + if ((*dot < '0') || (*dot > '9')) + return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); + + /* libfoo.x.y.z.so? */ + if ((suffix[0] < '0') || (suffix[0] > '9')) { + if ((dot = strrchr(slnkname,'.'))) + dot++; + else + return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); + + if ((*dot < '0') || (*dot > '9')) + return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); + + for (; *suffix; ) + *dot++ = *suffix++; + + *dot++ = 0; + } + /* destination symlink: dstdir/libfoo.so.x */ if ((size_t)snprintf(dlnkname,sizeof(dlnkname),"%s/%s", dstdir,slnkname) >= sizeof(dlnkname)) -- cgit v1.2.3