Hi! On Sat, 2011-10-15 at 15:51:11 +0200, Svante Signell wrote: > On Sat, 2011-10-15 at 01:20 +0200, Guillem Jover wrote: > > After considering this, I think it would be a better option and way more > > portable to use realpath(path, NULL) when _POSIX_VERSION >= 200809L. > > Attached is an updated patch, taking Guillems comments into > consideration. We are looking forward to se it applied in the next > Debian release of pax (and in upstream in due time).
> diff -ur pax-20090728/file_subs.c pax-20090728.modified/file_subs.c > --- pax-20090728/file_subs.c 2009-07-28 17:38:28.000000000 +0000 > +++ pax-20090728.modified/file_subs.c 2011-10-15 12:56:46.000000000 +0000 > @@ -374,8 +374,15 @@ > if (strcmp(NM_TAR, argv0) == 0 && Lflag) { > while (lstat(nm, &sb) == 0 && > S_ISLNK(sb.st_mode)) { > + target = malloc(sb.st_size + 1); > + if (target == NULL) { > + oerrno = ENOMEM; > + syswarn(1, oerrno, > + "Insufficient memory"); > + return(-1); > + } > len = readlink(nm, target, > - sizeof target - 1); > + sb.st_size); It might make sense to use sb.st_size + 1 and verify there's not been truncation in between, please see the example code at: <http://man7.org/linux/man-pages/online/pages/man2/readlink.2.html> > if (len == -1) { > syswarn(0, errno, > "cannot follow symlink %s in > chain for %s", > diff -ur pax-20090728/tables.c pax-20090728.modified/tables.c > --- pax-20090728/tables.c 2009-07-28 17:38:28.000000000 +0000 > +++ pax-20090728.modified/tables.c 2011-10-15 13:39:29.000000000 +0000 > @@ -55,6 +55,7 @@ > #include "pax.h" > #include "tables.h" > #include "extern.h" > +#include "features.h" > > /* > * Routines for controlling the contents of all the different databases pax > @@ -1126,13 +1127,21 @@ > add_dir(char *name, struct stat *psb, int frc_mode) > { > DIRDATA *dblk; > +#if (_POSIX_C_SOURCE - 0) >= 200809L > + char *rp = NULL; > +#else > char realname[MAXPATHLEN], *rp; > +#endif Unfortunately both "features.h" and _POSIX_C_SOURCE are non-portable. The latter is a user defined variable, it does not specify what the system supports, but what the user requests, also both are GNUisms. The correct way to check for this is to include <unistd.h> and check for _POSIX_VERSION, as I pointed out initially. More into at: <http://sourceforge.net/apps/mediawiki/predef/index.php?title=Standards> thanks, guillem -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org