CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
prepared the code for the addition of the INSTALL rule
[pkgutils-cross.git] / libtar-1.2.11-reduce_mem_usage.patch
1 diff -ru libtar-1.2.11/lib/extract.c libtar-1.2.11-new/lib/extract.c
2 --- libtar-1.2.11/lib/extract.c 2003-03-03 00:58:07.000000000 +0100
3 +++ libtar-1.2.11-new/lib/extract.c 2003-10-03 15:07:46.000000000 +0200
4 @@ -28,14 +28,6 @@
5 #endif
6
7
8 -struct linkname
9 -{
10 - char ln_save[MAXPATHLEN];
11 - char ln_real[MAXPATHLEN];
12 -};
13 -typedef struct linkname linkname_t;
14 -
15 -
16 static int
17 tar_set_file_perms(TAR *t, char *realname)
18 {
19 @@ -98,7 +90,9 @@
20 tar_extract_file(TAR *t, char *realname)
21 {
22 int i;
23 - linkname_t *lnp;
24 + char *lnp;
25 + int pathname_len;
26 + int realname_len;
27
28 if (t->options & TAR_NOOVERWRITE)
29 {
30 @@ -137,11 +131,13 @@
31 if (i != 0)
32 return i;
33
34 - lnp = (linkname_t *)calloc(1, sizeof(linkname_t));
35 + pathname_len = strlen(th_get_pathname(t)) + 1;
36 + realname_len = strlen(realname) + 1;
37 + lnp = (char *)calloc(1, pathname_len + realname_len);
38 if (lnp == NULL)
39 return -1;
40 - strlcpy(lnp->ln_save, th_get_pathname(t), sizeof(lnp->ln_save));
41 - strlcpy(lnp->ln_real, realname, sizeof(lnp->ln_real));
42 + strcpy(&lnp[0], th_get_pathname(t));
43 + strcpy(&lnp[pathname_len], realname);
44 #ifdef DEBUG
45 printf("tar_extract_file(): calling libtar_hash_add(): key=\"%s\", "
46 "value=\"%s\"\n", th_get_pathname(t), realname);
47 @@ -288,7 +284,7 @@
48 {
49 char *filename;
50 char *linktgt = NULL;
51 - linkname_t *lnp;
52 + char *lnp;
53 libtar_hashptr_t hp;
54
55 if (!TH_ISLNK(t))
56 @@ -304,8 +300,8 @@
57 if (libtar_hash_getkey(t->h, &hp, th_get_linkname(t),
58 (libtar_matchfunc_t)libtar_str_match) != 0)
59 {
60 - lnp = (linkname_t *)libtar_hashptr_data(&hp);
61 - linktgt = lnp->ln_real;
62 + lnp = (char *)libtar_hashptr_data(&hp);
63 + linktgt = &lnp[strlen(lnp) + 1];
64 }
65 else
66 linktgt = th_get_linkname(t);