Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 487686
Collapse All | Expand All

(-)a/libtar/lib/decode.c (-3 / +34 lines)
Lines 21-44 Link Here
21
# include <string.h>
21
# include <string.h>
22
#endif
22
#endif
23
23
24
char *
25
safer_name_suffix (char const *file_name)
26
{
27
       char const *p, *t;
28
       p = t = file_name;
29
       while (*p)
30
       {
31
               if (p[0] == '.' && p[0] == p[1] && p[2] == '/')
32
               {
33
                       p += 3;
34
                       t = p;
35
               }
36
               /* advance pointer past the next slash */
37
               while (*p && (p++)[0] != '/');
38
       }
39
40
       if (!*t)
41
       {
42
               t = ".";
43
       }
44
45
       if (t != file_name)
46
       {
47
               /* TODO: warn somehow that the path was modified */
48
       }
49
       return (char*)t;
50
}
51
24
52
25
/* determine full path name */
53
/* determine full path name */
26
char *
54
char *
27
th_get_pathname(TAR *t)
55
th_get_pathname(TAR *t)
28
{
56
{
29
	static TLS_THREAD char filename[MAXPATHLEN];
57
	static TLS_THREAD char filename[MAXPATHLEN];
58
	char *safer_name;
30
59
31
	if (t->th_buf.gnu_longname)
60
	if (t->th_buf.gnu_longname)
32
		return t->th_buf.gnu_longname;
61
               return safer_name_suffix(t->th_buf.gnu_longname);
62
63
       safer_name = safer_name_suffix(t->th_buf.name);
33
64
34
	if (t->th_buf.prefix[0] != '\0')
65
	if (t->th_buf.prefix[0] != '\0')
35
	{
66
	{
36
		snprintf(filename, sizeof(filename), "%.155s/%.100s",
67
		snprintf(filename, sizeof(filename), "%.155s/%.100s",
37
			 t->th_buf.prefix, t->th_buf.name);
68
			 t->th_buf.prefix, safer_name);
38
		return filename;
69
		return filename;
39
	}
70
	}
40
71
41
	snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name);
72
	snprintf(filename, sizeof(filename), "%.100s", safer_name);
42
	return filename;
73
	return filename;
43
}
74
}
44
75
(-)a/libtar/lib/extract.c (-3 / +3 lines)
Lines 305-311 Link Here
305
		linktgt = &lnp[strlen(lnp) + 1];
305
		linktgt = &lnp[strlen(lnp) + 1];
306
	}
306
	}
307
	else
307
	else
308
		linktgt = th_get_linkname(t);
308
		linktgt = safer_name_suffix(th_get_linkname(t));
309
309
310
#ifdef DEBUG
310
#ifdef DEBUG
311
	printf("  ==> extracting: %s (link to %s)\n", filename, linktgt);
311
	printf("  ==> extracting: %s (link to %s)\n", filename, linktgt);
Lines 343-351 Link Here
343
343
344
#ifdef DEBUG
344
#ifdef DEBUG
345
	printf("  ==> extracting: %s (symlink to %s)\n",
345
	printf("  ==> extracting: %s (symlink to %s)\n",
346
	       filename, th_get_linkname(t));
346
	       filename, safer_name_suffix(th_get_linkname(t)));
347
#endif
347
#endif
348
	if (symlink(th_get_linkname(t), filename) == -1)
348
	if (symlink(safer_name_suffix(th_get_linkname(t)), filename) == -1)
349
	{
349
	{
350
#ifdef DEBUG
350
#ifdef DEBUG
351
		perror("symlink()");
351
		perror("symlink()");
(-)a/libtar/lib/internal.h (+1 lines)
Lines 15-20 Link Here
15
15
16
#include <libtar.h>
16
#include <libtar.h>
17
17
18
char* safer_name_suffix(char const*);
18
#ifdef TLS
19
#ifdef TLS
19
#define TLS_THREAD TLS
20
#define TLS_THREAD TLS
20
#else
21
#else

Return to bug 487686