From 3c03b34ecac2d81e9c1b3d291525f2ad29661256 Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Fri, 17 Jun 2016 21:10:08 -0400
Subject: slbt_mri_argument(): properly handle absolute path arg.

---
 src/helper/slbt_archive_import.c | 19 +++++++++++++------
 1 file 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)))
-- 
cgit v1.2.3