1 --- pax-20090728.orig/pax.c
3 @@ -105,7 +105,7 @@ char *dirptr; /* destination dir in a c
4 char *ltmfrmt; /* -v locale time format (if any) */
5 char *argv0; /* root of argv[0] */
6 sigset_t s_mask; /* signal mask for cleanup critical sect */
7 -FILE *listf = stderr; /* file pointer to print file list to */
8 +FILE *listf; /* file pointer to print file list to */
9 char *tempfile; /* tempfile to use for mkstemp(3) */
10 char *tempbase; /* basename of tempfile to use for mkstemp(3) */
12 @@ -235,6 +235,12 @@ main(int argc, char **argv)
17 + * On some systems, stderr is not a constant, so we initialize listf
18 + * immediately to emulate the behavior.
23 * Keep a reference to cwd, so we can always come back home.
25 --- pax-20090728.orig/ar_subs.c
26 +++ pax-20090728/ar_subs.c
27 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: a
29 #include <sys/types.h>
33 #include <sys/param.h>
35 --- pax-20090728.orig/cache.c
36 +++ pax-20090728/cache.c
37 @@ -200,7 +200,11 @@ name_uid(uid_t uid, int frc)
38 * No entry for this uid, we will add it
49 @@ -266,7 +270,11 @@ name_gid(gid_t gid, int frc)
50 * No entry for this gid, we will add it
61 @@ -333,7 +341,11 @@ uid_name(char *name, uid_t *uid)
73 @@ -396,7 +408,11 @@ gid_name(char *name, gid_t *gid)
85 --- pax-20090728.orig/pax.h
86 +++ pax-20090728/pax.h
87 @@ -242,3 +242,8 @@ typedef struct oplist {
90 #define _TFILE_BASE "paxXXXXXXXXXX"
92 +/* hack since we're pulling routines in from OpenBSD library to this dir */
93 +size_t strlcpy(char *, const char *, size_t);
94 +char * vis(char *, int, int, int);
96 --- pax-20090728.orig/sel_subs.c
97 +++ pax-20090728/sel_subs.c
98 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: s
100 #include <sys/types.h>
101 #include <sys/time.h>
103 #include <sys/stat.h>
104 #include <sys/param.h>
106 @@ -52,12 +53,14 @@ static const char rcsid[] = "$OpenBSD: s
114 #include "sel_subs.h"
117 +#define TM_YEAR_BASE 1900
119 static int str_sec(const char *, time_t *);
120 static int usr_match(ARCHD *);
121 static int grp_match(ARCHD *);
123 +++ pax-20090728/types.h
126 + * Copyright (c) 1982, 1986, 1991, 1993
127 + * The Regents of the University of California. All rights reserved.
128 + * (c) UNIX System Laboratories, Inc.
129 + * All or some portions of this file are derived from material licensed
130 + * to the University of California by American Telephone and Telegraph
131 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
132 + * the permission of UNIX System Laboratories, Inc.
134 + * Redistribution and use in source and binary forms, with or without
135 + * modification, are permitted provided that the following conditions
137 + * 1. Redistributions of source code must retain the above copyright
138 + * notice, this list of conditions and the following disclaimer.
139 + * 2. Redistributions in binary form must reproduce the above copyright
140 + * notice, this list of conditions and the following disclaimer in the
141 + * documentation and/or other materials provided with the distribution.
142 + * 3. All advertising materials mentioning features or use of this software
143 + * must display the following acknowledgement:
144 + * This product includes software developed by the University of
145 + * California, Berkeley and its contributors.
146 + * 4. Neither the name of the University nor the names of its contributors
147 + * may be used to endorse or promote products derived from this software
148 + * without specific prior written permission.
150 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
151 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
152 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
153 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
154 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
155 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
156 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
157 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
158 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
159 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
162 + * @(#)types.h 8.4 (Berkeley) 1/21/94
163 + * $Id: types.h,v 1.1 2001-07-23 05:20:01 bdale Exp $
166 +#ifndef _SYS_TYPES_H_
167 +#define _SYS_TYPES_H_
169 +#include <sys/cdefs.h>
171 +/* Machine type dependent parameters. */
172 +#include <machine/endian.h>
174 +#ifndef _POSIX_SOURCE
175 +typedef unsigned char u_char;
176 +typedef unsigned short u_short;
177 +typedef unsigned int u_int;
178 +typedef unsigned long u_long;
179 +typedef unsigned short ushort; /* Sys V compatibility */
180 +typedef unsigned int uint; /* Sys V compatibility */
183 +typedef unsigned long long u_quad_t; /* quads */
184 +typedef long long quad_t;
185 +typedef quad_t * qaddr_t;
187 +typedef char * caddr_t; /* core address */
188 +typedef long daddr_t; /* disk address */
189 +typedef unsigned long dev_t; /* device number */
190 +typedef unsigned long fixpt_t; /* fixed point number */
191 +typedef unsigned long gid_t; /* group id */
192 +typedef unsigned long ino_t; /* inode number */
193 +typedef unsigned short mode_t; /* permissions */
194 +typedef unsigned short nlink_t; /* link count */
195 +typedef quad_t off_t; /* file offset */
196 +typedef long pid_t; /* process id */
197 +typedef long segsz_t; /* segment size */
198 +typedef long swblk_t; /* swap offset */
199 +typedef unsigned long uid_t; /* user id */
202 + * This belongs in unistd.h, but is placed here to ensure that programs
203 + * casting the second parameter of lseek to off_t will get the correct
204 + * version of lseek.
208 +off_t lseek __P((int, off_t, int));
212 +#ifndef _POSIX_SOURCE
214 + * minor() gives a cookie instead of an index since we don't want to
215 + * change the meanings of bits 0-15 or waste time and space shifting
216 + * bits 16-31 for devices that don't use them.
218 +#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
219 +#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
220 +#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) /* create dev_t */
223 +#include <machine/ansi.h>
224 +#include <machine/types.h>
226 +#ifdef _BSD_CLOCK_T_
227 +typedef _BSD_CLOCK_T_ clock_t;
228 +#undef _BSD_CLOCK_T_
232 +typedef _BSD_SIZE_T_ size_t;
236 +#ifdef _BSD_SSIZE_T_
237 +typedef _BSD_SSIZE_T_ ssize_t;
238 +#undef _BSD_SSIZE_T_
242 +typedef _BSD_TIME_T_ time_t;
246 +#ifndef _POSIX_SOURCE
247 +#define NBBY 8 /* number of bits in a byte */
250 + * Select uses bit masks of file descriptors in longs. These macros
251 + * manipulate such bit fields (the filesystem macros use chars).
252 + * FD_SETSIZE may be defined by the user, but the default here should
253 + * be enough for most uses.
256 +#define FD_SETSIZE 256
259 +typedef long fd_mask;
260 +#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
263 +#define howmany(x, y) (((x)+((y)-1))/(y))
266 +typedef struct fd_set {
267 + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
270 +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
271 +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
272 +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
273 +#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
274 +#define FD_ZERO(p) bzero(p, sizeof(*(p)))
276 +#if defined(__STDC__) && defined(KERNEL)
278 + * Forward structure declarations for function prototypes. We include the
279 + * common structures that cross subsystem boundaries here; others are mostly
280 + * used in the same place that the structure is defined.
292 +#endif /* !_POSIX_SOURCE */
293 +#endif /* !_SYS_TYPES_H_ */
295 +++ pax-20090728/strmode.h
298 + * Copyright (c) 1990, 1993
299 + * The Regents of the University of California. All rights reserved.
301 + * Redistribution and use in source and binary forms, with or without
302 + * modification, are permitted provided that the following conditions
304 + * 1. Redistributions of source code must retain the above copyright
305 + * notice, this list of conditions and the following disclaimer.
306 + * 2. Redistributions in binary form must reproduce the above copyright
307 + * notice, this list of conditions and the following disclaimer in the
308 + * documentation and/or other materials provided with the distribution.
309 + * 3. All advertising materials mentioning features or use of this software
310 + * must display the following acknowledgement:
311 + * This product includes software developed by the University of
312 + * California, Berkeley and its contributors.
313 + * 4. Neither the name of the University nor the names of its contributors
314 + * may be used to endorse or promote products derived from this software
315 + * without specific prior written permission.
317 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
318 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
319 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
320 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
321 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
322 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
323 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
324 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
325 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
326 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
330 +void strmode(mode_t mode, char *p);
331 --- pax-20090728.orig/tar.c
332 +++ pax-20090728/tar.c
333 @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: t
334 #endif /* not lint */
336 #include <sys/types.h>
337 +#include <sys/sysmacros.h>
338 #include <sys/time.h>
339 #include <sys/stat.h>
340 #include <sys/param.h>
341 @@ -763,6 +764,12 @@ ustar_rd(ARCHD *arcn, char *buf)
343 * see if the filename is split into two parts. if, so joint the parts.
344 * we copy the prefix first and add a / between the prefix and name.
346 + * the length passed to l_strncpy must be the length of the field
347 + * being copied *from*, since these fields are NOT null terminated
348 + * when full. the destination buffer is plenty big enough to hold
349 + * the longest supported ustar path length, so there's no need
350 + * to check against that.
353 if (*(hd->prefix) != '\0') {
354 @@ -1072,6 +1079,15 @@ ustar_wr(ARCHD *arcn)
355 strncpy(hd->uname, name_uid(arcn->sb.st_uid, 0), sizeof(hd->uname));
356 strncpy(hd->gname, name_gid(arcn->sb.st_gid, 0), sizeof(hd->gname));
359 + * Always add devmajor and devminor
361 + if (ul_oct ((u_long) MAJOR (arcn->sb.st_rdev), hd->devmajor,
362 + sizeof (hd->devmajor), 3) ||
363 + ul_oct ((u_long) MINOR (arcn->sb.st_rdev), hd->devminor,
364 + sizeof (hd->devminor), 3))
368 * calculate and store the checksum write the header to the archive
369 * return 0 tells the caller to now write the file data, 1 says no data
371 +++ pax-20090728/strmode.c
374 + * Copyright (c) 1990, 1993
375 + * The Regents of the University of California. All rights reserved.
377 + * Redistribution and use in source and binary forms, with or without
378 + * modification, are permitted provided that the following conditions
380 + * 1. Redistributions of source code must retain the above copyright
381 + * notice, this list of conditions and the following disclaimer.
382 + * 2. Redistributions in binary form must reproduce the above copyright
383 + * notice, this list of conditions and the following disclaimer in the
384 + * documentation and/or other materials provided with the distribution.
385 + * 3. All advertising materials mentioning features or use of this software
386 + * must display the following acknowledgement:
387 + * This product includes software developed by the University of
388 + * California, Berkeley and its contributors.
389 + * 4. Neither the name of the University nor the names of its contributors
390 + * may be used to endorse or promote products derived from this software
391 + * without specific prior written permission.
393 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
394 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
395 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
396 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
397 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
398 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
399 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
400 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
401 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
402 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
406 +#if defined(LIBC_SCCS) && !defined(lint)
407 +static char sccsid[] = "@(#)strmode.c 8.1 (Berkeley) 6/4/93";
408 +#endif /* LIBC_SCCS and not lint */
410 +#include <sys/types.h>
411 +#include <sys/stat.h>
416 + register mode_t mode;
420 + switch (mode & S_IFMT) {
421 + case S_IFDIR: /* directory */
424 + case S_IFCHR: /* character special */
427 + case S_IFBLK: /* block special */
430 + case S_IFREG: /* regular */
433 + case S_IFLNK: /* symbolic link */
436 + case S_IFSOCK: /* socket */
440 + case S_IFIFO: /* fifo */
444 + default: /* unknown */
449 + if (mode & S_IRUSR)
453 + if (mode & S_IWUSR)
457 + switch (mode & (S_IXUSR | S_ISUID)) {
467 + case S_IXUSR | S_ISUID:
472 + if (mode & S_IRGRP)
476 + if (mode & S_IWGRP)
480 + switch (mode & (S_IXGRP | S_ISGID)) {
490 + case S_IXGRP | S_ISGID:
495 + if (mode & S_IROTH)
499 + if (mode & S_IWOTH)
503 + switch (mode & (S_IXOTH | S_ISVTX)) {
513 + case S_IXOTH | S_ISVTX:
517 + *p++ = ' '; /* will be a '+' if ACL's implemented */
520 --- pax-20090728.orig/Makefile
521 +++ pax-20090728/Makefile
524 SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
525 gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
527 -MAN= pax.1 tar.1 cpio.1
528 -LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
529 + tar.c tty_subs.c fgetln.c strmode.c strlcpy.c vis.c
533 -.include <bsd.prog.mk>
534 +CFLAGS= -Wall -O2 -g -DLONG_OFF_T\
535 + -DNET2_STAT -D_PATH_DEFTAPE=\"/dev/rmt0\" -DDEBIAN -D_GNU_SOURCE
540 + $(CC) $(CFLAGS) $(OBJS) -o $@ $(LIBS)
549 + install -d -m 755 $(DESTDIR)$(prefix)/bin $(DESTDIR)$(prefix)/share/man/man1
550 + install -s -m 755 $(PROG) $(DESTDIR)$(prefix)/bin
551 + install -m 644 $(MAN) $(DESTDIR)$(prefix)/share/man/man1
553 +++ pax-20090728/strlcpy.c
555 +/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
558 + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
560 + * Permission to use, copy, modify, and distribute this software for any
561 + * purpose with or without fee is hereby granted, provided that the above
562 + * copyright notice and this permission notice appear in all copies.
564 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
565 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
566 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
567 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
568 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
569 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
570 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
573 +#include <sys/types.h>
577 + * Copy src to string dst of size siz. At most siz-1 characters
578 + * will be copied. Always NUL terminates (unless siz == 0).
579 + * Returns strlen(src); if retval >= siz, truncation occurred.
582 +strlcpy(char *dst, const char *src, size_t siz)
585 + const char *s = src;
588 + /* Copy as many bytes as will fit */
591 + if ((*d++ = *s++) == '\0')
596 + /* Not enough room in dst, add NUL and traverse rest of src */
599 + *d = '\0'; /* NUL-terminate dst */
604 + return(s - src - 1); /* count does not include NUL */
606 --- pax-20090728.orig/ar_io.c
607 +++ pax-20090728/ar_io.c
608 @@ -1248,8 +1248,9 @@ ar_next(void)
612 - * starts the gzip compression/decompression process as a child, using magic
613 - * to keep the fd the same in the calling function (parent).
614 + * starts the compress, gzip or bzip2 compression/decompression process
615 + * as a child, using magic to keep the fd the same in the calling function
619 ar_start_gzip(int fd, const char *gzip_program, int wr)
621 +++ pax-20090728/Makefile.bsd
623 +# $OpenBSD: Makefile,v 1.9 1997/09/21 11:35:28 deraadt Exp $
625 +# To install on versions prior to BSD 4.4 the following may have to be
626 +# defined with CFLAGS +=
628 +# -DNET2_STAT Use NET2 or older stat structure. The version of the
629 +# stat structure is easily determined by looking at the
630 +# basic type of an off_t (often defined in the file:
631 +# /usr/include/sys/types.h). If off_t is a long (and is
632 +# NOT A quad) then you must define NET2_STAT.
633 +# This define is important, as if you do have a quad_t
634 +# off_t and define NET2_STAT, pax will compile but will
637 +# -DNET2_FTS Use the older NET2 fts. To identify the version,
638 +# examine the file: /usr/include/fts.h. If FTS_COMFOLLOW
639 +# is not defined then you must define NET2_FTS.
640 +# Pax may not compile if this not (un)defined properly.
642 +# -DNET2_REGEX Use the older regexp.h not regex.h. The regex version
643 +# is determined by looking at the value returned by
644 +# regexec() (man 3 regexec). If regexec return a 1 for
645 +# success (and NOT a 0 for success) you have the older
646 +# regex routines and must define NET2_REGEX.
647 +# Pax may not compile if this not (un)defined properly.
650 +SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
651 + gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
653 +MAN= pax.1 tar.1 cpio.1
654 +LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
656 +.include <bsd.prog.mk>
658 +++ pax-20090728/vis.c
660 +/* $OpenBSD: vis.c,v 1.19 2005/09/01 17:15:49 millert Exp $ */
662 + * Copyright (c) 1989, 1993
663 + * The Regents of the University of California. All rights reserved.
665 + * Redistribution and use in source and binary forms, with or without
666 + * modification, are permitted provided that the following conditions
668 + * 1. Redistributions of source code must retain the above copyright
669 + * notice, this list of conditions and the following disclaimer.
670 + * 2. Redistributions in binary form must reproduce the above copyright
671 + * notice, this list of conditions and the following disclaimer in the
672 + * documentation and/or other materials provided with the distribution.
673 + * 3. Neither the name of the University nor the names of its contributors
674 + * may be used to endorse or promote products derived from this software
675 + * without specific prior written permission.
677 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
678 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
679 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
680 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
681 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
682 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
683 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
684 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
685 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
686 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
690 +#include <sys/types.h>
696 +#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
697 +#define isvisible(c) \
698 + (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) && \
699 + (((c) != '*' && (c) != '?' && (c) != '[' && (c) != '#') || \
700 + (flag & VIS_GLOB) == 0) && isgraph((u_char)(c))) || \
701 + ((flag & VIS_SP) == 0 && (c) == ' ') || \
702 + ((flag & VIS_TAB) == 0 && (c) == '\t') || \
703 + ((flag & VIS_NL) == 0 && (c) == '\n') || \
704 + ((flag & VIS_SAFE) && ((c) == '\b' || \
705 + (c) == '\007' || (c) == '\r' || \
706 + isgraph((u_char)(c)))))
709 + * vis - visually encode characters
712 +vis(char *dst, int c, int flag, int nextc)
714 + if (isvisible(c)) {
716 + if (c == '\\' && (flag & VIS_NOSLASH) == 0)
722 + if (flag & VIS_CSTYLE) {
759 + if (isoctal(nextc)) {
766 + if (((c & 0177) == ' ') || (flag & VIS_OCTAL) ||
767 + ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) {
769 + *dst++ = ((u_char)c >> 6 & 07) + '0';
770 + *dst++ = ((u_char)c >> 3 & 07) + '0';
771 + *dst++ = ((u_char)c & 07) + '0';
774 + if ((flag & VIS_NOSLASH) == 0)
780 + if (iscntrl((u_char)c)) {
796 + * strvis, strnvis, strvisx - visually encode characters from src into dst
798 + * Dst must be 4 times the size of src to account for possible
799 + * expansion. The length of dst, not including the trailing NULL,
802 + * Strnvis will write no more than siz-1 bytes (and will NULL terminate).
803 + * The number of bytes needed to fully encode the string is returned.
805 + * Strvisx encodes exactly len bytes from src into dst.
806 + * This is useful for encoding a block of data.
809 +strvis(char *dst, const char *src, int flag)
814 + for (start = dst; (c = *src);)
815 + dst = vis(dst, c, flag, *++src);
817 + return (dst - start);
821 +strnvis(char *dst, const char *src, size_t siz, int flag)
828 + for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) {
829 + if (isvisible(c)) {
832 + if (c == '\\' && (flag & VIS_NOSLASH) == 0) {
833 + /* need space for the extra '\\' */
844 + i = vis(tbuf, c, flag, *++src) - tbuf;
845 + if (dst + i <= end) {
846 + memcpy(dst, tbuf, i);
856 + if (dst + i > end) {
857 + /* adjust return value for truncation */
859 + dst += vis(tbuf, c, flag, *++src) - tbuf;
861 + return (dst - start);
865 +strvisx(char *dst, const char *src, size_t len, int flag)
870 + for (start = dst; len > 1; len--) {
872 + dst = vis(dst, c, flag, *++src);
875 + dst = vis(dst, *src, flag, '\0');
877 + return (dst - start);
879 --- pax-20090728.orig/gen_subs.c
880 +++ pax-20090728/gen_subs.c
881 @@ -43,19 +43,23 @@ static const char rcsid[] = "$OpenBSD: g
882 #endif /* not lint */
884 #include <sys/types.h>
885 +#include <sys/sysmacros.h>
886 #include <sys/time.h>
888 #include <sys/stat.h>
889 #include <sys/param.h>
902 +#include "strmode.h"
905 * a collection of general purpose subroutines used by pax
907 @@ -65,6 +69,9 @@ static const char rcsid[] = "$OpenBSD: g
911 +#define DAYSPERNYEAR 365
912 +/* #define SECSPERDAY 86400 */
913 +/* #define VIS_CSTYLE 0 */
914 #define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY)
915 #define CURFRMT "%b %e %H:%M"
916 #define OLDFRMT "%b %e %Y"
917 @@ -205,7 +212,7 @@ safe_print(const char *str, FILE *fp)
919 * if printing to a tty, use vis(3) to print special characters.
921 - if (isatty(fileno(fp))) {
922 + if (0 && isatty(fileno(fp))) {
923 for (cp = str; *cp; cp++) {
924 (void)vis(visbuf, cp[0], VIS_CSTYLE, cp[1]);
925 (void)fputs(visbuf, fp);
926 --- pax-20090728.orig/pax.1
927 +++ pax-20090728/pax.1
928 @@ -1143,7 +1143,7 @@ completes it will exit with a non-zero e
931 utility is compliant with the
938 +++ pax-20090728/fgetln.c
940 +/* fgetline: Read one line of input and return a pointer to
941 + that line. Necessary space is obtained from malloc.
942 + (char *) NULL is returned on EOF.
944 + Andy Dougherty doughera@lafcol.lafayette.edu
946 + Lafayette College, Easton PA 18042
948 + Successive calls to fgetline() overwrite the original buffer.
949 + If you want to preserve the data, you must do something like
950 + the following (the +1's are for '\0' characters):
952 + tmp = fgetline(fp);
953 + ntmp = Ealloc(strlen(tmp)+1, sizeof(char));
954 + strncpy(ntmp, tmp, strlen(tmp)+1);
956 + A line is defined as all characters up to (and including) the next
957 + newline character or end of file.
958 + The string is terminated by a NULL character.
960 + * Version 1.1 A. Dougherty 2/7/94
961 + Don't call realloc() just to save a few bytes.
962 + Check return value from realloc(). (NULL is allowed under POSIX,
963 + though I've never hit it.)
965 + * Version 1.0 A. Dougherty 2/27/91
967 + This fgetline implementation was written by Andrew Dougherty
968 + <doughera@lafayette.edu>. I hearby place it in the public domain.
969 + As a courtesy, please leave my name attached to the source.
971 + This code comes with no warranty whatsoever, and I take no
972 + responsibility for any consequences of its use.
975 +/* Algorithm: A local static buffer "buf" is maintained. The current
976 + length (space available) is in the static variable "avail".
977 + Read in characters into this buffer. If need more space, call
980 + Aside: We have computed strlen(buf) in this function. It
981 + seems a shame to throw it away.
986 +#include <sys/types.h>
988 +#define LINELEN 128 /* A decent guess that should only rarely be
991 +#define OK_TO_WASTE 512 /* Don't bother trying to realloc() back to
992 + a smaller buffer if you'd only end up
993 + wasting OK_TO_WASTE bytes.
996 +void *Emalloc(size_t len) /* David */
1002 + perror("out of memory (Emalloc)");
1009 +void *Erealloc(char *p, size_t len) /* David */
1011 + p=realloc(p, len);
1013 + perror("out of memory (Erealloc)");
1021 +fgetln(FILE *fp, size_t *length)
1023 + static char *buf = NULL;
1024 + static size_t avail = 0;
1026 + char *p; /* Temporary used for reducing length. */
1031 + buf = (char *) Emalloc(LINELEN * sizeof(char));
1035 + len = 0; /* Current length */
1037 + while ((c=getc(fp)) != EOF)
1039 + if (len >= avail) /* Need to ask for space */
1041 + avail += LINELEN; /* Maybe avail *= 2 would be better */
1042 + buf = (char *) Erealloc((void *) buf, avail * sizeof(char));
1050 + if (c == EOF && len == 0)
1051 + return (char *) NULL;
1053 + /* Add terminating '\0' character */
1054 + if (len >= avail) /* Need 1 more space */
1055 + buf = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1058 + /* Should we bother to try reclaiming memory? (Otherwise, this
1059 + function will hold onto enough memory to hold the longest
1060 + line for the entire duration of the program.)
1062 + if (avail - len > OK_TO_WASTE)
1064 + p = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1074 --- pax-20090728.orig/cpio.c
1075 +++ pax-20090728/cpio.c
1076 @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: c
1077 #endif /* not lint */
1079 #include <sys/types.h>
1080 +#include <sys/sysmacros.h>
1081 #include <sys/time.h>
1082 #include <sys/stat.h>
1083 #include <sys/param.h>
1085 +++ pax-20090728/tzfile.h
1088 + * Ported to Linux's Second Extended File System as part of the
1089 + * dump and restore backup suit
1090 + * Remy Card <Remy.Card@freenix.fr>, 1994, 1995
1095 + * Copyright (c) 1988, 1993
1096 + * The Regents of the University of California. All rights reserved.
1098 + * This code is derived from software contributed to Berkeley by
1099 + * Arthur David Olson of the National Cancer Institute.
1101 + * Redistribution and use in source and binary forms, with or without
1102 + * modification, are permitted provided that the following conditions
1104 + * 1. Redistributions of source code must retain the above copyright
1105 + * notice, this list of conditions and the following disclaimer.
1106 + * 2. Redistributions in binary form must reproduce the above copyright
1107 + * notice, this list of conditions and the following disclaimer in the
1108 + * documentation and/or other materials provided with the distribution.
1109 + * 3. All advertising materials mentioning features or use of this software
1110 + * must display the following acknowledgement:
1111 + * This product includes software developed by the University of
1112 + * California, Berkeley and its contributors.
1113 + * 4. Neither the name of the University nor the names of its contributors
1114 + * may be used to endorse or promote products derived from this software
1115 + * without specific prior written permission.
1117 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1118 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1119 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1120 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1121 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1122 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1123 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1124 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1125 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1126 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1129 + * @(#)tzfile.h 8.1 (Berkeley) 6/2/93
1136 + * Information about time zone files.
1138 + /* Time zone object file directory */
1139 +#define TZDIR "/usr/share/zoneinfo"
1140 +#define TZDEFAULT "/etc/localtime"
1141 +#define TZDEFRULES "posixrules"
1144 +** Each file begins with. . .
1148 + char tzh_reserved[24]; /* reserved for future use */
1149 + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
1150 + char tzh_leapcnt[4]; /* coded number of leap seconds */
1151 + char tzh_timecnt[4]; /* coded number of transition times */
1152 + char tzh_typecnt[4]; /* coded number of local time types */
1153 + char tzh_charcnt[4]; /* coded number of abbr. chars */
1157 +** . . .followed by. . .
1159 +** tzh_timecnt (char [4])s coded transition times a la time(2)
1160 +** tzh_timecnt (unsigned char)s types of local time starting at above
1161 +** tzh_typecnt repetitions of
1162 +** one (char [4]) coded GMT offset in seconds
1163 +** one (unsigned char) used to set tm_isdst
1164 +** one (unsigned char) that's an abbreviation list index
1165 +** tzh_charcnt (char)s '\0'-terminated zone abbreviations
1166 +** tzh_leapcnt repetitions of
1167 +** one (char [4]) coded leap second transition times
1168 +** one (char [4]) total correction after above
1169 +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
1170 +** time is standard time, if FALSE,
1171 +** transition time is wall clock time
1172 +** if absent, transition times are
1173 +** assumed to be wall clock time
1177 +** In the current implementation, "tzset()" refuses to deal with files that
1178 +** exceed any of the limits below.
1182 +** The TZ_MAX_TIMES value below is enough to handle a bit more than a
1183 +** year's worth of solar time (corrected daily to the nearest second) or
1184 +** 138 years of Pacific Presidential Election time
1185 +** (where there are three time zone transitions every fourth year).
1187 +#define TZ_MAX_TIMES 370
1189 +#define NOSOLAR /* 4BSD doesn't currently handle solar time */
1192 +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
1194 +#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
1197 +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
1199 +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
1201 +#define SECSPERMIN 60
1202 +#define MINSPERHOUR 60
1203 +#define HOURSPERDAY 24
1204 +#define DAYSPERWEEK 7
1205 +#define DAYSPERNYEAR 365
1206 +#define DAYSPERLYEAR 366
1207 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
1208 +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
1209 +#define MONSPERYEAR 12
1211 +#define TM_SUNDAY 0
1212 +#define TM_MONDAY 1
1213 +#define TM_TUESDAY 2
1214 +#define TM_WEDNESDAY 3
1215 +#define TM_THURSDAY 4
1216 +#define TM_FRIDAY 5
1217 +#define TM_SATURDAY 6
1219 +#define TM_JANUARY 0
1220 +#define TM_FEBRUARY 1
1226 +#define TM_AUGUST 7
1227 +#define TM_SEPTEMBER 8
1228 +#define TM_OCTOBER 9
1229 +#define TM_NOVEMBER 10
1230 +#define TM_DECEMBER 11
1232 +#define TM_YEAR_BASE 1900
1234 +#define EPOCH_YEAR 1970
1235 +#define EPOCH_WDAY TM_THURSDAY
1238 +** Accurate only for the past couple of centuries;
1239 +** that will probably do.
1242 +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
1244 +#endif /* !_TZFILE_H_ */
1246 +++ pax-20090728/vis.h
1248 +/* $OpenBSD: vis.h,v 1.11 2005/08/09 19:38:31 millert Exp $ */
1249 +/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
1252 + * Copyright (c) 1990 The Regents of the University of California.
1253 + * All rights reserved.
1255 + * Redistribution and use in source and binary forms, with or without
1256 + * modification, are permitted provided that the following conditions
1258 + * 1. Redistributions of source code must retain the above copyright
1259 + * notice, this list of conditions and the following disclaimer.
1260 + * 2. Redistributions in binary form must reproduce the above copyright
1261 + * notice, this list of conditions and the following disclaimer in the
1262 + * documentation and/or other materials provided with the distribution.
1263 + * 3. Neither the name of the University nor the names of its contributors
1264 + * may be used to endorse or promote products derived from this software
1265 + * without specific prior written permission.
1267 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1268 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1269 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1270 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1271 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1272 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1273 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1274 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1275 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1276 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1279 + * @(#)vis.h 5.9 (Berkeley) 4/3/91
1286 + * to select alternate encoding format
1288 +#define VIS_OCTAL 0x01 /* use octal \ddd format */
1289 +#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
1292 + * to alter set of characters encoded (default is to encode all
1293 + * non-graphic except space, tab, and newline).
1295 +#define VIS_SP 0x04 /* also encode space */
1296 +#define VIS_TAB 0x08 /* also encode tab */
1297 +#define VIS_NL 0x10 /* also encode newline */
1298 +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
1299 +#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
1304 +#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
1305 +#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */
1308 + * unvis return codes
1310 +#define UNVIS_VALID 1 /* character valid */
1311 +#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
1312 +#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
1313 +#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
1314 +#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
1319 +#define UNVIS_END 1 /* no more characters */
1321 +#include <sys/cdefs.h>
1324 +char *vis(char *, int, int, int);
1325 +int strvis(char *, const char *, int);
1326 +int strnvis(char *, const char *, size_t, int)
1327 + __attribute__ ((__bounded__(__string__,1,3)));
1328 +int strvisx(char *, const char *, size_t, int)
1329 + __attribute__ ((__bounded__(__string__,1,3)));
1330 +int strunvis(char *, const char *);
1331 +int unvis(char *, char, int *, int);
1332 +ssize_t strnunvis(char *, const char *, size_t)
1333 + __attribute__ ((__bounded__(__string__,1,3)));
1337 +#endif /* !_VIS_H_ */
1339 +++ pax-20090728/fgetln.h
1341 +/* fgetline: Read one line of input and return a pointer to
1342 + that line. Necessary space is obtained from malloc.
1343 + (char *) NULL is returned on EOF.
1345 + Andy Dougherty doughera@lafcol.lafayette.edu
1347 + Lafayette College, Easton PA 18042
1349 + This fgetline implementation was written by Andrew Dougherty
1350 + <doughera@lafayette.edu>. I hearby place it in the public domain.
1351 + As a courtesy, please leave my name attached to the source.
1353 + This code comes with no warranty whatsoever, and I take no
1354 + responsibility for any consequences of its use.
1357 +char *fgetln(FILE *fp, size_t *length);
1358 --- pax-20090728.orig/options.c
1359 +++ pax-20090728/options.c
1360 @@ -60,6 +60,8 @@ static const char rcsid[] = "$OpenBSD: o
1364 +#include "fgetln.h" /* added, David */
1367 * Routines which handle command line options
1369 @@ -72,7 +74,7 @@ static int no_op(void);
1370 static void printflg(unsigned int);
1371 static int c_frmt(const void *, const void *);
1372 static off_t str_offt(char *);
1373 -static char *getline(FILE *fp);
1374 +static char *bsd_getline(FILE *fp);
1375 static void pax_options(int, char **);
1376 static void pax_usage(void);
1377 static void tar_options(int, char **);
1378 @@ -882,7 +884,7 @@ tar_options(int argc, char **argv)
1379 paxwarn(1, "Unable to open file '%s' for read", file);
1382 - while ((str = getline(fp)) != NULL) {
1383 + while ((str = bsd_getline(fp)) != NULL) {
1384 if (pat_add(str, dir) < 0)
1387 @@ -961,7 +963,7 @@ tar_options(int argc, char **argv)
1388 paxwarn(1, "Unable to open file '%s' for read", file);
1391 - while ((str = getline(fp)) != NULL) {
1392 + while ((str = bsd_getline(fp)) != NULL) {
1393 if (ftree_add(str, 0) < 0)
1396 @@ -1183,7 +1185,7 @@ cpio_options(int argc, char **argv)
1397 paxwarn(1, "Unable to open file '%s' for read", optarg);
1400 - while ((str = getline(fp)) != NULL) {
1401 + while ((str = bsd_getline(fp)) != NULL) {
1405 @@ -1282,7 +1284,7 @@ cpio_options(int argc, char **argv)
1406 * no read errors allowed on updates/append operation!
1409 - while ((str = getline(stdin)) != NULL) {
1410 + while ((str = bsd_getline(stdin)) != NULL) {
1413 if (getline_error) {
1414 @@ -1459,7 +1461,7 @@ str_offt(char *val)
1415 if ((num == LONG_MAX) || (num <= 0) || (expr == val))
1417 num = strtoq(val, &expr, 0);
1418 - if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
1419 + if ((num == LLONG_MAX) || (num <= 0) || (expr == val))
1423 @@ -1511,7 +1513,7 @@ str_offt(char *val)
1428 +bsd_getline(FILE *f)