altomaltes / cross / slibtool

Forked from cross/slibtool 2 years ago
Clone

3c03b3 slbt_mri_argument(): properly handle absolute path arg.

Authored and Committed by midipix 8 years ago
    slbt_mri_argument(): properly handle absolute path arg.
    
        
src/helper/slbt_archive_import.c CHANGED
@@ -21,18 +21,25 @@ static char * slbt_mri_argument(
21
21
{
22
22
int i;
23
23
char * lnk;
24
+ char * target;
24
25
char mricwd[PATH_MAX];
25
- char target[PATH_MAX];
26
+ char dstbuf[PATH_MAX];
26
27
27
28
if ((!(strchr(arg,'+'))) && (!(strchr(arg,'-'))))
28
29
return arg;
29
30
30
- if (!(getcwd(mricwd,sizeof(mricwd))))
31
- return 0;
31
+ if (arg[0] == '/')
32
+ target = arg;
33
+ else {
34
+ if (!(getcwd(mricwd,sizeof(mricwd))))
35
+ return 0;
36
+
37
+ if ((size_t)snprintf(dstbuf,sizeof(dstbuf),"%s/%s",
38
+ mricwd,arg) >= sizeof(dstbuf))
39
+ return 0;
32
40
33
- if ((size_t)snprintf(target,sizeof(target),"%s/%s",
34
- mricwd,arg) >= sizeof(target))
41
+ target = dstbuf;
42
+ }
35
- return 0;
36
43
37
44
for (i=0,lnk=0; i<1024 && !lnk; i++) {
38
45
if (!(tmpnam(buf)))