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-31 17:39:17.000000000 +0000
8 - char target[MAXPATHLEN];
10 char *nm = arcn->name;
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) {
21 + "Insufficient memory");
24 len = readlink(nm, target,
29 "cannot follow symlink %s in chain for %s",
34 + if (len > sb.st_size) {
36 + "symlink %s increased in size between lstat() and readlink() for %s",
47 "%s skipped. Sockets cannot be copied or extracted",
52 res = symlink(arcn->ln_name, nm);
55 paxwarn(0, "%s has an unknown file type, skipping",
62 * we failed to make the node
65 - if ((ign = unlnk_exist(nm, arcn->type)) < 0)
66 + if ((ign = unlnk_exist(nm, arcn->type)) < 0) {
74 if (nodirs || chk_path(nm,arcn->sb.st_uid,arcn->sb.st_gid) < 0) {
75 syswarn(1, oerrno, "Could not create: %s", nm);
82 * symlinks are done now.
84 - if (arcn->type == PAX_SLK)
85 + if (arcn->type == PAX_SLK) {
91 * IMPORTANT SECURITY NOTE:
95 set_ftime(nm, arcn->sb.st_mtime, arcn->sb.st_atime, 0);
100 diff -ur pax-20090728/tables.c pax-20090728.modified/tables.c
101 --- pax-20090728/tables.c 2009-07-28 17:38:28.000000000 +0000
102 +++ pax-20090728.modified/tables.c 2011-10-31 17:17:26.000000000 +0000
110 * Routines for controlling the contents of all the different databases pax
111 @@ -1126,13 +1127,21 @@
112 add_dir(char *name, struct stat *psb, int frc_mode)
115 +#if (_POSIX_VERSION >= 200809L)
118 char realname[MAXPATHLEN], *rp;
124 if (havechd && *name != '/') {
125 +#if (_POSIX_VERSION >= 200809L)
126 + if ((rp = realpath(name, NULL)) == NULL) {
128 if ((rp = realpath(name, realname)) == NULL) {
130 paxwarn(1, "Cannot canonicalize %s", name);
133 @@ -1143,6 +1152,9 @@
135 paxwarn(1, "Unable to store mode and times for created"
136 " directory: %s", name);
137 +#if (_POSIX_VERSION >= 200809L)
143 @@ -1152,6 +1164,9 @@
144 if ((dblk->name = strdup(name)) == NULL) {
145 paxwarn(1, "Unable to store mode and times for created"
146 " directory: %s", name);
147 +#if (_POSIX_VERSION >= 200809L)
152 dblk->mode = psb->st_mode & 0xffff;
153 @@ -1159,6 +1174,9 @@
154 dblk->atime = psb->st_atime;
155 dblk->frc_mode = frc_mode;
157 +#if (_POSIX_VERSION >= 200809L)