]> git.pld-linux.org Git - packages/libtar.git/blob - libtar-fix-memleak.patch
7fa75a030ba31364c8c2645e4855e27bdaeeeb51
[packages/libtar.git] / libtar-fix-memleak.patch
1 diff -urN 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     2008-08-19 11:46:58.000000000 +0200
4 @@ -21,6 +21,7 @@
5  
6  #ifdef STDC_HEADERS
7  # include <stdlib.h>
8 +# include <string.h>
9  #endif
10  
11  #ifdef HAVE_UNISTD_H
12 @@ -99,6 +100,7 @@
13  {
14         int i;
15         linkname_t *lnp;
16 +       char *pathname;
17  
18         if (t->options & TAR_NOOVERWRITE)
19         {
20 @@ -140,12 +142,14 @@
21         lnp = (linkname_t *)calloc(1, sizeof(linkname_t));
22         if (lnp == NULL)
23                 return -1;
24 -       strlcpy(lnp->ln_save, th_get_pathname(t), sizeof(lnp->ln_save));
25 +       pathname = th_get_pathname(t);
26 +       strlcpy(lnp->ln_save, pathname, sizeof(lnp->ln_save));
27         strlcpy(lnp->ln_real, realname, sizeof(lnp->ln_real));
28  #ifdef DEBUG
29         printf("tar_extract_file(): calling libtar_hash_add(): key=\"%s\", "
30 -              "value=\"%s\"\n", th_get_pathname(t), realname);
31 +              "value=\"%s\"\n", pathname, realname);
32  #endif
33 +       free(pathname);
34         if (libtar_hash_add(t->h, lnp) != 0)
35                 return -1;
36  
37 diff -urN libtar-1.2.11/lib/output.c libtar-1.2.11.new/lib/output.c
38 --- libtar-1.2.11/lib/output.c  2003-01-07 02:41:00.000000000 +0100
39 +++ libtar-1.2.11.new/lib/output.c      2008-08-19 11:46:58.000000000 +0200
40 @@ -71,6 +71,7 @@
41         char groupname[_POSIX_LOGIN_NAME_MAX];
42         time_t mtime;
43         struct tm *mtm;
44 +       char *pathname;
45  
46  #ifdef HAVE_STRFTIME
47         char timebuf[18];
48 @@ -114,7 +115,9 @@
49                mtm->tm_mday, mtm->tm_hour, mtm->tm_min, mtm->tm_year + 1900);
50  #endif
51  
52 -       printf(" %s", th_get_pathname(t));
53 +       pathname = th_get_pathname(t);
54 +       printf(" %s", pathname);
55 +       free(pathname);
56  
57         if (TH_ISSYM(t) || TH_ISLNK(t))
58         {
59 diff -urN libtar-1.2.11/lib/wrapper.c libtar-1.2.11.new/lib/wrapper.c
60 --- libtar-1.2.11/lib/wrapper.c 2003-01-07 02:41:00.000000000 +0100
61 +++ libtar-1.2.11.new/lib/wrapper.c     2008-08-19 11:46:58.000000000 +0200
62 @@ -76,6 +76,7 @@
63                         snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
64                 else
65                         strlcpy(buf, filename, sizeof(buf));
66 +               free(filename);
67  #ifdef DEBUG
68                 printf("    tar_extract_all(): calling tar_extract_file(t, "
69                        "\"%s\")\n", buf);
This page took 0.084743 seconds and 2 git commands to generate.