68bcbd545960b4eeb5ee0802c39b64ac0dd0acc7
[debian/pax] / debian / patches / fix_FTBFS4Hurd.diff
1 diff -ur pax-20090728/file_subs.c pax-20090728.modified/file_subs.c
2 --- pax-20090728/file_subs.c    2009-07-28 17:38:28.000000000 +0000
3 +++ pax-20090728.modified/file_subs.c   2011-10-15 12:56:46.000000000 +0000
4 @@ -351,7 +351,7 @@
5         int pass = 0;
6         mode_t file_mode;
7         struct stat sb;
8 -       char target[MAXPATHLEN];
9 +       char *target = NULL;
10         char *nm = arcn->name;
11         int len;
12  
13 @@ -374,8 +374,15 @@
14                         if (strcmp(NM_TAR, argv0) == 0 && Lflag) {
15                                 while (lstat(nm, &sb) == 0 &&
16                                     S_ISLNK(sb.st_mode)) {
17 +                                       target = malloc(sb.st_size + 1);
18 +                                       if (target == NULL) {
19 +                                               oerrno = ENOMEM;
20 +                                               syswarn(1, oerrno,
21 +                                                   "Insufficient memory");
22 +                                               return(-1);
23 +                                       }
24                                         len = readlink(nm, target,
25 -                                           sizeof target - 1);
26 +                                           sb.st_size);
27                                         if (len == -1) {
28                                                 syswarn(0, errno,
29                                                    "cannot follow symlink %s in chain for %s",
30 @@ -411,6 +418,7 @@
31                         paxwarn(0,
32                             "%s skipped. Sockets cannot be copied or extracted",
33                             nm);
34 +                       free(target);
35                         return(-1);
36                 case PAX_SLK:
37                         res = symlink(arcn->ln_name, nm);
38 @@ -425,6 +433,7 @@
39                          */
40                         paxwarn(0, "%s has an unknown file type, skipping",
41                                 nm);
42 +                       free(target);
43                         return(-1);
44                 }
45  
46 @@ -440,14 +449,17 @@
47                  * we failed to make the node
48                  */
49                 oerrno = errno;
50 -               if ((ign = unlnk_exist(nm, arcn->type)) < 0)
51 +               if ((ign = unlnk_exist(nm, arcn->type)) < 0) {
52 +                       free(target);
53                         return(-1);
54 +               }
55  
56                 if (++pass <= 1)
57                         continue;
58  
59                 if (nodirs || chk_path(nm,arcn->sb.st_uid,arcn->sb.st_gid) < 0) {
60                         syswarn(1, oerrno, "Could not create: %s", nm);
61 +                       free(target);
62                         return(-1);
63                 }
64         }
65 @@ -465,8 +477,10 @@
66         /*
67          * symlinks are done now.
68          */
69 -       if (arcn->type == PAX_SLK)
70 +       if (arcn->type == PAX_SLK) {
71 +               free(target);
72                 return(0);
73 +       }
74  
75         /*
76          * IMPORTANT SECURITY NOTE:
77 @@ -517,6 +531,7 @@
78  
79         if (patime || pmtime)
80                 set_ftime(nm, arcn->sb.st_mtime, arcn->sb.st_atime, 0);
81 +       free(target);
82         return(0);
83  }
84  
85 diff -ur pax-20090728/tables.c pax-20090728.modified/tables.c
86 --- pax-20090728/tables.c       2009-07-28 17:38:28.000000000 +0000
87 +++ pax-20090728.modified/tables.c      2011-10-15 13:39:29.000000000 +0000
88 @@ -55,6 +55,7 @@
89  #include "pax.h"
90  #include "tables.h"
91  #include "extern.h"
92 +#include "features.h"
93  
94  /*
95   * Routines for controlling the contents of all the different databases pax
96 @@ -1126,13 +1127,21 @@
97  add_dir(char *name, struct stat *psb, int frc_mode)
98  {
99         DIRDATA *dblk;
100 +#if (_POSIX_C_SOURCE - 0) >= 200809L
101 +       char *rp = NULL;
102 +#else
103         char realname[MAXPATHLEN], *rp;
104 +#endif
105  
106         if (dirp == NULL)
107                 return;
108  
109         if (havechd && *name != '/') {
110 +#if (_POSIX_C_SOURCE - 0) >= 200809L
111 +               if ((rp = realpath(name, NULL)) == NULL) {
112 +#else
113                 if ((rp = realpath(name, realname)) == NULL) {
114 +#endif
115                         paxwarn(1, "Cannot canonicalize %s", name);
116                         return;
117                 }
118 @@ -1143,6 +1152,9 @@
119                 if (dblk == NULL) {
120                         paxwarn(1, "Unable to store mode and times for created"
121                             " directory: %s", name);
122 +#if (_POSIX_C_SOURCE - 0) >= 200809L
123 +                       free(rp);
124 +#endif
125                         return;
126                 }
127                 dirp = dblk;
128 @@ -1152,6 +1164,9 @@
129         if ((dblk->name = strdup(name)) == NULL) {
130                 paxwarn(1, "Unable to store mode and times for created"
131                     " directory: %s", name);
132 +#if (_POSIX_C_SOURCE - 0) >= 200809L
133 +               free(rp);
134 +#endif
135                 return;
136         }
137         dblk->mode = psb->st_mode & 0xffff;
138 @@ -1159,6 +1174,9 @@
139         dblk->atime = psb->st_atime;
140         dblk->frc_mode = frc_mode;
141         ++dircnt;
142 +#if (_POSIX_C_SOURCE - 0) >= 200809L
143 +       free(rp);
144 +#endif
145  }
146  
147  /*