From ca36f56b368ece9c0f3b276a456e5c5a7ce3c151 Mon Sep 17 00:00:00 2001 From: midipix Date: Nov 10 2018 22:35:32 +0000 Subject: install mode: host flavors: properly support suffixed suffixes. --- 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))