summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-06-17 21:10:08 -0400
committermidipix <writeonce@midipix.org>2016-06-17 21:10:08 -0400
commit3c03b34ecac2d81e9c1b3d291525f2ad29661256 (patch)
tree023b5e0fd946288a163de9e4a6a3881b76f22d2b
parentf7eed4054df0cbda12213ec6d6c493f6af1c88ae (diff)
downloadslibtool-3c03b34ecac2d81e9c1b3d291525f2ad29661256.tar.bz2
slibtool-3c03b34ecac2d81e9c1b3d291525f2ad29661256.tar.xz
slbt_mri_argument(): properly handle absolute path arg.
-rw-r--r--src/helper/slbt_archive_import.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c
index 059ff37..1d1d5e1 100644
--- a/src/helper/slbt_archive_import.c
+++ b/src/helper/slbt_archive_import.c
@@ -21,18 +21,25 @@ static char * slbt_mri_argument(
{
int i;
char * lnk;
+ char * target;
char mricwd[PATH_MAX];
- char target[PATH_MAX];
+ char dstbuf[PATH_MAX];
if ((!(strchr(arg,'+'))) && (!(strchr(arg,'-'))))
return arg;
- if (!(getcwd(mricwd,sizeof(mricwd))))
- return 0;
+ if (arg[0] == '/')
+ target = arg;
+ else {
+ if (!(getcwd(mricwd,sizeof(mricwd))))
+ return 0;
+
+ if ((size_t)snprintf(dstbuf,sizeof(dstbuf),"%s/%s",
+ mricwd,arg) >= sizeof(dstbuf))
+ return 0;
- if ((size_t)snprintf(target,sizeof(target),"%s/%s",
- mricwd,arg) >= sizeof(target))
- return 0;
+ target = dstbuf;
+ }
for (i=0,lnk=0; i<1024 && !lnk; i++) {
if (!(tmpnam(buf)))