1 Description: <short summary of the patch>
2 TODO: Put a short summary on the line above and replace this paragraph
3 with a longer explanation of this change. Complete the meta-information
4 with other relevant fields (see below for details). To make it easier, the
5 information below has been extracted from the changelog. Adjust it or drop
8 pax (1:20090728-3) UNRELEASED; urgency=low
11 Author: Bdale Garbee <bdale@gag.com>
14 The information above should follow the Patch Tagging Guidelines, please
15 checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
16 are templates for supplementary fields that you might want to add:
18 Origin: <vendor|upstream|other>, <url of original patch>
19 Bug: <url in upstream bugtracker>
20 Bug-Debian: http://bugs.debian.org/<bugnumber>
21 Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
22 Forwarded: <no|not-needed|url proving that it has been forwarded>
23 Reviewed-By: <name and email of someone who approved the patch>
24 Last-Update: <YYYY-MM-DD>
26 --- pax-20090728.orig/pax.c
27 +++ pax-20090728/pax.c
28 @@ -105,7 +105,7 @@ char *dirptr; /* destination dir in a c
29 char *ltmfrmt; /* -v locale time format (if any) */
30 char *argv0; /* root of argv[0] */
31 sigset_t s_mask; /* signal mask for cleanup critical sect */
32 -FILE *listf = stderr; /* file pointer to print file list to */
33 +FILE *listf; /* file pointer to print file list to */
34 char *tempfile; /* tempfile to use for mkstemp(3) */
35 char *tempbase; /* basename of tempfile to use for mkstemp(3) */
37 @@ -235,6 +235,12 @@ main(int argc, char **argv)
42 + * On some systems, stderr is not a constant, so we initialize listf
43 + * immediately to emulate the behavior.
48 * Keep a reference to cwd, so we can always come back home.
50 --- pax-20090728.orig/ar_subs.c
51 +++ pax-20090728/ar_subs.c
52 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: a
54 #include <sys/types.h>
58 #include <sys/param.h>
60 --- pax-20090728.orig/cache.c
61 +++ pax-20090728/cache.c
62 @@ -200,7 +200,11 @@ name_uid(uid_t uid, int frc)
63 * No entry for this uid, we will add it
74 @@ -266,7 +270,11 @@ name_gid(gid_t gid, int frc)
75 * No entry for this gid, we will add it
86 @@ -333,7 +341,11 @@ uid_name(char *name, uid_t *uid)
98 @@ -396,7 +408,11 @@ gid_name(char *name, gid_t *gid)
110 --- pax-20090728.orig/pax.h
111 +++ pax-20090728/pax.h
112 @@ -242,3 +242,8 @@ typedef struct oplist {
115 #define _TFILE_BASE "paxXXXXXXXXXX"
117 +/* hack since we're pulling routines in from OpenBSD library to this dir */
118 +size_t strlcpy(char *, const char *, size_t);
119 +char * vis(char *, int, int, int);
121 --- pax-20090728.orig/sel_subs.c
122 +++ pax-20090728/sel_subs.c
123 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: s
125 #include <sys/types.h>
126 #include <sys/time.h>
128 #include <sys/stat.h>
129 #include <sys/param.h>
131 @@ -52,12 +53,14 @@ static const char rcsid[] = "$OpenBSD: s
139 #include "sel_subs.h"
142 +#define TM_YEAR_BASE 1900
144 static int str_sec(const char *, time_t *);
145 static int usr_match(ARCHD *);
146 static int grp_match(ARCHD *);
148 +++ pax-20090728/types.h
151 + * Copyright (c) 1982, 1986, 1991, 1993
152 + * The Regents of the University of California. All rights reserved.
153 + * (c) UNIX System Laboratories, Inc.
154 + * All or some portions of this file are derived from material licensed
155 + * to the University of California by American Telephone and Telegraph
156 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
157 + * the permission of UNIX System Laboratories, Inc.
159 + * Redistribution and use in source and binary forms, with or without
160 + * modification, are permitted provided that the following conditions
162 + * 1. Redistributions of source code must retain the above copyright
163 + * notice, this list of conditions and the following disclaimer.
164 + * 2. Redistributions in binary form must reproduce the above copyright
165 + * notice, this list of conditions and the following disclaimer in the
166 + * documentation and/or other materials provided with the distribution.
167 + * 3. All advertising materials mentioning features or use of this software
168 + * must display the following acknowledgement:
169 + * This product includes software developed by the University of
170 + * California, Berkeley and its contributors.
171 + * 4. Neither the name of the University nor the names of its contributors
172 + * may be used to endorse or promote products derived from this software
173 + * without specific prior written permission.
175 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
176 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
177 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
179 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
180 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
181 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
182 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
183 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
184 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
187 + * @(#)types.h 8.4 (Berkeley) 1/21/94
188 + * $Id: types.h,v 1.1 2001-07-23 05:20:01 bdale Exp $
191 +#ifndef _SYS_TYPES_H_
192 +#define _SYS_TYPES_H_
194 +#include <sys/cdefs.h>
196 +/* Machine type dependent parameters. */
197 +#include <machine/endian.h>
199 +#ifndef _POSIX_SOURCE
200 +typedef unsigned char u_char;
201 +typedef unsigned short u_short;
202 +typedef unsigned int u_int;
203 +typedef unsigned long u_long;
204 +typedef unsigned short ushort; /* Sys V compatibility */
205 +typedef unsigned int uint; /* Sys V compatibility */
208 +typedef unsigned long long u_quad_t; /* quads */
209 +typedef long long quad_t;
210 +typedef quad_t * qaddr_t;
212 +typedef char * caddr_t; /* core address */
213 +typedef long daddr_t; /* disk address */
214 +typedef unsigned long dev_t; /* device number */
215 +typedef unsigned long fixpt_t; /* fixed point number */
216 +typedef unsigned long gid_t; /* group id */
217 +typedef unsigned long ino_t; /* inode number */
218 +typedef unsigned short mode_t; /* permissions */
219 +typedef unsigned short nlink_t; /* link count */
220 +typedef quad_t off_t; /* file offset */
221 +typedef long pid_t; /* process id */
222 +typedef long segsz_t; /* segment size */
223 +typedef long swblk_t; /* swap offset */
224 +typedef unsigned long uid_t; /* user id */
227 + * This belongs in unistd.h, but is placed here to ensure that programs
228 + * casting the second parameter of lseek to off_t will get the correct
229 + * version of lseek.
233 +off_t lseek __P((int, off_t, int));
237 +#ifndef _POSIX_SOURCE
239 + * minor() gives a cookie instead of an index since we don't want to
240 + * change the meanings of bits 0-15 or waste time and space shifting
241 + * bits 16-31 for devices that don't use them.
243 +#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
244 +#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
245 +#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) /* create dev_t */
248 +#include <machine/ansi.h>
249 +#include <machine/types.h>
251 +#ifdef _BSD_CLOCK_T_
252 +typedef _BSD_CLOCK_T_ clock_t;
253 +#undef _BSD_CLOCK_T_
257 +typedef _BSD_SIZE_T_ size_t;
261 +#ifdef _BSD_SSIZE_T_
262 +typedef _BSD_SSIZE_T_ ssize_t;
263 +#undef _BSD_SSIZE_T_
267 +typedef _BSD_TIME_T_ time_t;
271 +#ifndef _POSIX_SOURCE
272 +#define NBBY 8 /* number of bits in a byte */
275 + * Select uses bit masks of file descriptors in longs. These macros
276 + * manipulate such bit fields (the filesystem macros use chars).
277 + * FD_SETSIZE may be defined by the user, but the default here should
278 + * be enough for most uses.
281 +#define FD_SETSIZE 256
284 +typedef long fd_mask;
285 +#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
288 +#define howmany(x, y) (((x)+((y)-1))/(y))
291 +typedef struct fd_set {
292 + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
295 +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
296 +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
297 +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
298 +#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
299 +#define FD_ZERO(p) bzero(p, sizeof(*(p)))
301 +#if defined(__STDC__) && defined(KERNEL)
303 + * Forward structure declarations for function prototypes. We include the
304 + * common structures that cross subsystem boundaries here; others are mostly
305 + * used in the same place that the structure is defined.
317 +#endif /* !_POSIX_SOURCE */
318 +#endif /* !_SYS_TYPES_H_ */
320 +++ pax-20090728/strmode.h
323 + * Copyright (c) 1990, 1993
324 + * The Regents of the University of California. All rights reserved.
326 + * Redistribution and use in source and binary forms, with or without
327 + * modification, are permitted provided that the following conditions
329 + * 1. Redistributions of source code must retain the above copyright
330 + * notice, this list of conditions and the following disclaimer.
331 + * 2. Redistributions in binary form must reproduce the above copyright
332 + * notice, this list of conditions and the following disclaimer in the
333 + * documentation and/or other materials provided with the distribution.
334 + * 3. All advertising materials mentioning features or use of this software
335 + * must display the following acknowledgement:
336 + * This product includes software developed by the University of
337 + * California, Berkeley and its contributors.
338 + * 4. Neither the name of the University nor the names of its contributors
339 + * may be used to endorse or promote products derived from this software
340 + * without specific prior written permission.
342 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
343 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
344 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
345 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
346 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
347 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
348 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
349 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
350 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
355 +void strmode(mode_t mode, char *p);
356 --- pax-20090728.orig/tar.c
357 +++ pax-20090728/tar.c
358 @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: t
359 #endif /* not lint */
361 #include <sys/types.h>
362 +#include <sys/sysmacros.h>
363 #include <sys/time.h>
364 #include <sys/stat.h>
365 #include <sys/param.h>
366 @@ -763,6 +764,12 @@ ustar_rd(ARCHD *arcn, char *buf)
368 * see if the filename is split into two parts. if, so joint the parts.
369 * we copy the prefix first and add a / between the prefix and name.
371 + * the length passed to l_strncpy must be the length of the field
372 + * being copied *from*, since these fields are NOT null terminated
373 + * when full. the destination buffer is plenty big enough to hold
374 + * the longest supported ustar path length, so there's no need
375 + * to check against that.
378 if (*(hd->prefix) != '\0') {
379 @@ -1072,6 +1079,15 @@ ustar_wr(ARCHD *arcn)
380 strncpy(hd->uname, name_uid(arcn->sb.st_uid, 0), sizeof(hd->uname));
381 strncpy(hd->gname, name_gid(arcn->sb.st_gid, 0), sizeof(hd->gname));
384 + * Always add devmajor and devminor
386 + if (ul_oct ((u_long) MAJOR (arcn->sb.st_rdev), hd->devmajor,
387 + sizeof (hd->devmajor), 3) ||
388 + ul_oct ((u_long) MINOR (arcn->sb.st_rdev), hd->devminor,
389 + sizeof (hd->devminor), 3))
393 * calculate and store the checksum write the header to the archive
394 * return 0 tells the caller to now write the file data, 1 says no data
396 +++ pax-20090728/strmode.c
399 + * Copyright (c) 1990, 1993
400 + * The Regents of the University of California. All rights reserved.
402 + * Redistribution and use in source and binary forms, with or without
403 + * modification, are permitted provided that the following conditions
405 + * 1. Redistributions of source code must retain the above copyright
406 + * notice, this list of conditions and the following disclaimer.
407 + * 2. Redistributions in binary form must reproduce the above copyright
408 + * notice, this list of conditions and the following disclaimer in the
409 + * documentation and/or other materials provided with the distribution.
410 + * 3. All advertising materials mentioning features or use of this software
411 + * must display the following acknowledgement:
412 + * This product includes software developed by the University of
413 + * California, Berkeley and its contributors.
414 + * 4. Neither the name of the University nor the names of its contributors
415 + * may be used to endorse or promote products derived from this software
416 + * without specific prior written permission.
418 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
419 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
420 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
421 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
422 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
423 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
424 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
425 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
426 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
427 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
431 +#if defined(LIBC_SCCS) && !defined(lint)
432 +static char sccsid[] = "@(#)strmode.c 8.1 (Berkeley) 6/4/93";
433 +#endif /* LIBC_SCCS and not lint */
435 +#include <sys/types.h>
436 +#include <sys/stat.h>
441 + register mode_t mode;
445 + switch (mode & S_IFMT) {
446 + case S_IFDIR: /* directory */
449 + case S_IFCHR: /* character special */
452 + case S_IFBLK: /* block special */
455 + case S_IFREG: /* regular */
458 + case S_IFLNK: /* symbolic link */
461 + case S_IFSOCK: /* socket */
465 + case S_IFIFO: /* fifo */
469 + default: /* unknown */
474 + if (mode & S_IRUSR)
478 + if (mode & S_IWUSR)
482 + switch (mode & (S_IXUSR | S_ISUID)) {
492 + case S_IXUSR | S_ISUID:
497 + if (mode & S_IRGRP)
501 + if (mode & S_IWGRP)
505 + switch (mode & (S_IXGRP | S_ISGID)) {
515 + case S_IXGRP | S_ISGID:
520 + if (mode & S_IROTH)
524 + if (mode & S_IWOTH)
528 + switch (mode & (S_IXOTH | S_ISVTX)) {
538 + case S_IXOTH | S_ISVTX:
542 + *p++ = ' '; /* will be a '+' if ACL's implemented */
545 --- pax-20090728.orig/Makefile
546 +++ pax-20090728/Makefile
549 SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
550 gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
552 -MAN= pax.1 tar.1 cpio.1
553 -LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
554 + tar.c tty_subs.c fgetln.c strmode.c strlcpy.c vis.c
558 -.include <bsd.prog.mk>
559 +CFLAGS= -Wall -O2 -g -DLONG_OFF_T\
560 + -DNET2_STAT -D_PATH_DEFTAPE=\"/dev/rmt0\" -DDEBIAN -D_GNU_SOURCE
565 + $(CC) $(CFLAGS) $(OBJS) -o $@ $(LIBS)
574 + install -d -m 755 $(DESTDIR)$(prefix)/bin $(DESTDIR)$(prefix)/share/man/man1
575 + install -s -m 755 $(PROG) $(DESTDIR)$(prefix)/bin
576 + install -m 644 $(MAN) $(DESTDIR)$(prefix)/share/man/man1
578 +++ pax-20090728/strlcpy.c
580 +/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
583 + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
585 + * Permission to use, copy, modify, and distribute this software for any
586 + * purpose with or without fee is hereby granted, provided that the above
587 + * copyright notice and this permission notice appear in all copies.
589 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
590 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
591 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
592 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
593 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
594 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
595 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
598 +#include <sys/types.h>
602 + * Copy src to string dst of size siz. At most siz-1 characters
603 + * will be copied. Always NUL terminates (unless siz == 0).
604 + * Returns strlen(src); if retval >= siz, truncation occurred.
607 +strlcpy(char *dst, const char *src, size_t siz)
610 + const char *s = src;
613 + /* Copy as many bytes as will fit */
616 + if ((*d++ = *s++) == '\0')
621 + /* Not enough room in dst, add NUL and traverse rest of src */
624 + *d = '\0'; /* NUL-terminate dst */
629 + return(s - src - 1); /* count does not include NUL */
631 --- pax-20090728.orig/ar_io.c
632 +++ pax-20090728/ar_io.c
633 @@ -1248,8 +1248,9 @@ ar_next(void)
637 - * starts the gzip compression/decompression process as a child, using magic
638 - * to keep the fd the same in the calling function (parent).
639 + * starts the compress, gzip or bzip2 compression/decompression process
640 + * as a child, using magic to keep the fd the same in the calling function
644 ar_start_gzip(int fd, const char *gzip_program, int wr)
646 +++ pax-20090728/Makefile.bsd
648 +# $OpenBSD: Makefile,v 1.9 1997/09/21 11:35:28 deraadt Exp $
650 +# To install on versions prior to BSD 4.4 the following may have to be
651 +# defined with CFLAGS +=
653 +# -DNET2_STAT Use NET2 or older stat structure. The version of the
654 +# stat structure is easily determined by looking at the
655 +# basic type of an off_t (often defined in the file:
656 +# /usr/include/sys/types.h). If off_t is a long (and is
657 +# NOT A quad) then you must define NET2_STAT.
658 +# This define is important, as if you do have a quad_t
659 +# off_t and define NET2_STAT, pax will compile but will
662 +# -DNET2_FTS Use the older NET2 fts. To identify the version,
663 +# examine the file: /usr/include/fts.h. If FTS_COMFOLLOW
664 +# is not defined then you must define NET2_FTS.
665 +# Pax may not compile if this not (un)defined properly.
667 +# -DNET2_REGEX Use the older regexp.h not regex.h. The regex version
668 +# is determined by looking at the value returned by
669 +# regexec() (man 3 regexec). If regexec return a 1 for
670 +# success (and NOT a 0 for success) you have the older
671 +# regex routines and must define NET2_REGEX.
672 +# Pax may not compile if this not (un)defined properly.
675 +SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
676 + gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
678 +MAN= pax.1 tar.1 cpio.1
679 +LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
681 +.include <bsd.prog.mk>
683 +++ pax-20090728/vis.c
685 +/* $OpenBSD: vis.c,v 1.19 2005/09/01 17:15:49 millert Exp $ */
687 + * Copyright (c) 1989, 1993
688 + * The Regents of the University of California. All rights reserved.
690 + * Redistribution and use in source and binary forms, with or without
691 + * modification, are permitted provided that the following conditions
693 + * 1. Redistributions of source code must retain the above copyright
694 + * notice, this list of conditions and the following disclaimer.
695 + * 2. Redistributions in binary form must reproduce the above copyright
696 + * notice, this list of conditions and the following disclaimer in the
697 + * documentation and/or other materials provided with the distribution.
698 + * 3. Neither the name of the University nor the names of its contributors
699 + * may be used to endorse or promote products derived from this software
700 + * without specific prior written permission.
702 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
703 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
704 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
705 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
706 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
707 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
708 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
709 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
710 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
711 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
715 +#include <sys/types.h>
721 +#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
722 +#define isvisible(c) \
723 + (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) && \
724 + (((c) != '*' && (c) != '?' && (c) != '[' && (c) != '#') || \
725 + (flag & VIS_GLOB) == 0) && isgraph((u_char)(c))) || \
726 + ((flag & VIS_SP) == 0 && (c) == ' ') || \
727 + ((flag & VIS_TAB) == 0 && (c) == '\t') || \
728 + ((flag & VIS_NL) == 0 && (c) == '\n') || \
729 + ((flag & VIS_SAFE) && ((c) == '\b' || \
730 + (c) == '\007' || (c) == '\r' || \
731 + isgraph((u_char)(c)))))
734 + * vis - visually encode characters
737 +vis(char *dst, int c, int flag, int nextc)
739 + if (isvisible(c)) {
741 + if (c == '\\' && (flag & VIS_NOSLASH) == 0)
747 + if (flag & VIS_CSTYLE) {
784 + if (isoctal(nextc)) {
791 + if (((c & 0177) == ' ') || (flag & VIS_OCTAL) ||
792 + ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) {
794 + *dst++ = ((u_char)c >> 6 & 07) + '0';
795 + *dst++ = ((u_char)c >> 3 & 07) + '0';
796 + *dst++ = ((u_char)c & 07) + '0';
799 + if ((flag & VIS_NOSLASH) == 0)
805 + if (iscntrl((u_char)c)) {
821 + * strvis, strnvis, strvisx - visually encode characters from src into dst
823 + * Dst must be 4 times the size of src to account for possible
824 + * expansion. The length of dst, not including the trailing NULL,
827 + * Strnvis will write no more than siz-1 bytes (and will NULL terminate).
828 + * The number of bytes needed to fully encode the string is returned.
830 + * Strvisx encodes exactly len bytes from src into dst.
831 + * This is useful for encoding a block of data.
834 +strvis(char *dst, const char *src, int flag)
839 + for (start = dst; (c = *src);)
840 + dst = vis(dst, c, flag, *++src);
842 + return (dst - start);
846 +strnvis(char *dst, const char *src, size_t siz, int flag)
853 + for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) {
854 + if (isvisible(c)) {
857 + if (c == '\\' && (flag & VIS_NOSLASH) == 0) {
858 + /* need space for the extra '\\' */
869 + i = vis(tbuf, c, flag, *++src) - tbuf;
870 + if (dst + i <= end) {
871 + memcpy(dst, tbuf, i);
881 + if (dst + i > end) {
882 + /* adjust return value for truncation */
884 + dst += vis(tbuf, c, flag, *++src) - tbuf;
886 + return (dst - start);
890 +strvisx(char *dst, const char *src, size_t len, int flag)
895 + for (start = dst; len > 1; len--) {
897 + dst = vis(dst, c, flag, *++src);
900 + dst = vis(dst, *src, flag, '\0');
902 + return (dst - start);
904 --- pax-20090728.orig/gen_subs.c
905 +++ pax-20090728/gen_subs.c
906 @@ -43,19 +43,23 @@ static const char rcsid[] = "$OpenBSD: g
907 #endif /* not lint */
909 #include <sys/types.h>
910 +#include <sys/sysmacros.h>
911 #include <sys/time.h>
913 #include <sys/stat.h>
914 #include <sys/param.h>
927 +#include "strmode.h"
930 * a collection of general purpose subroutines used by pax
932 @@ -65,6 +69,9 @@ static const char rcsid[] = "$OpenBSD: g
936 +#define DAYSPERNYEAR 365
937 +/* #define SECSPERDAY 86400 */
938 +/* #define VIS_CSTYLE 0 */
939 #define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY)
940 #define CURFRMT "%b %e %H:%M"
941 #define OLDFRMT "%b %e %Y"
942 @@ -205,7 +212,7 @@ safe_print(const char *str, FILE *fp)
944 * if printing to a tty, use vis(3) to print special characters.
946 - if (isatty(fileno(fp))) {
947 + if (0 && isatty(fileno(fp))) {
948 for (cp = str; *cp; cp++) {
949 (void)vis(visbuf, cp[0], VIS_CSTYLE, cp[1]);
950 (void)fputs(visbuf, fp);
951 --- pax-20090728.orig/pax.1
952 +++ pax-20090728/pax.1
953 @@ -1143,7 +1143,7 @@ completes it will exit with a non-zero e
956 utility is compliant with the
963 +++ pax-20090728/fgetln.c
965 +/* fgetline: Read one line of input and return a pointer to
966 + that line. Necessary space is obtained from malloc.
967 + (char *) NULL is returned on EOF.
969 + Andy Dougherty doughera@lafcol.lafayette.edu
971 + Lafayette College, Easton PA 18042
973 + Successive calls to fgetline() overwrite the original buffer.
974 + If you want to preserve the data, you must do something like
975 + the following (the +1's are for '\0' characters):
977 + tmp = fgetline(fp);
978 + ntmp = Ealloc(strlen(tmp)+1, sizeof(char));
979 + strncpy(ntmp, tmp, strlen(tmp)+1);
981 + A line is defined as all characters up to (and including) the next
982 + newline character or end of file.
983 + The string is terminated by a NULL character.
985 + * Version 1.1 A. Dougherty 2/7/94
986 + Don't call realloc() just to save a few bytes.
987 + Check return value from realloc(). (NULL is allowed under POSIX,
988 + though I've never hit it.)
990 + * Version 1.0 A. Dougherty 2/27/91
992 + This fgetline implementation was written by Andrew Dougherty
993 + <doughera@lafayette.edu>. I hearby place it in the public domain.
994 + As a courtesy, please leave my name attached to the source.
996 + This code comes with no warranty whatsoever, and I take no
997 + responsibility for any consequences of its use.
1000 +/* Algorithm: A local static buffer "buf" is maintained. The current
1001 + length (space available) is in the static variable "avail".
1002 + Read in characters into this buffer. If need more space, call
1005 + Aside: We have computed strlen(buf) in this function. It
1006 + seems a shame to throw it away.
1010 +#include <stdlib.h>
1011 +#include <sys/types.h>
1013 +#define LINELEN 128 /* A decent guess that should only rarely be
1016 +#define OK_TO_WASTE 512 /* Don't bother trying to realloc() back to
1017 + a smaller buffer if you'd only end up
1018 + wasting OK_TO_WASTE bytes.
1021 +void *Emalloc(size_t len) /* David */
1027 + perror("out of memory (Emalloc)");
1034 +void *Erealloc(char *p, size_t len) /* David */
1036 + p=realloc(p, len);
1038 + perror("out of memory (Erealloc)");
1046 +fgetln(FILE *fp, size_t *length)
1048 + static char *buf = NULL;
1049 + static size_t avail = 0;
1051 + char *p; /* Temporary used for reducing length. */
1056 + buf = (char *) Emalloc(LINELEN * sizeof(char));
1060 + len = 0; /* Current length */
1062 + while ((c=getc(fp)) != EOF)
1064 + if (len >= avail) /* Need to ask for space */
1066 + avail += LINELEN; /* Maybe avail *= 2 would be better */
1067 + buf = (char *) Erealloc((void *) buf, avail * sizeof(char));
1075 + if (c == EOF && len == 0)
1076 + return (char *) NULL;
1078 + /* Add terminating '\0' character */
1079 + if (len >= avail) /* Need 1 more space */
1080 + buf = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1083 + /* Should we bother to try reclaiming memory? (Otherwise, this
1084 + function will hold onto enough memory to hold the longest
1085 + line for the entire duration of the program.)
1087 + if (avail - len > OK_TO_WASTE)
1089 + p = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1099 --- pax-20090728.orig/cpio.c
1100 +++ pax-20090728/cpio.c
1101 @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: c
1102 #endif /* not lint */
1104 #include <sys/types.h>
1105 +#include <sys/sysmacros.h>
1106 #include <sys/time.h>
1107 #include <sys/stat.h>
1108 #include <sys/param.h>
1110 +++ pax-20090728/tzfile.h
1113 + * Ported to Linux's Second Extended File System as part of the
1114 + * dump and restore backup suit
1115 + * Remy Card <Remy.Card@freenix.fr>, 1994, 1995
1120 + * Copyright (c) 1988, 1993
1121 + * The Regents of the University of California. All rights reserved.
1123 + * This code is derived from software contributed to Berkeley by
1124 + * Arthur David Olson of the National Cancer Institute.
1126 + * Redistribution and use in source and binary forms, with or without
1127 + * modification, are permitted provided that the following conditions
1129 + * 1. Redistributions of source code must retain the above copyright
1130 + * notice, this list of conditions and the following disclaimer.
1131 + * 2. Redistributions in binary form must reproduce the above copyright
1132 + * notice, this list of conditions and the following disclaimer in the
1133 + * documentation and/or other materials provided with the distribution.
1134 + * 3. All advertising materials mentioning features or use of this software
1135 + * must display the following acknowledgement:
1136 + * This product includes software developed by the University of
1137 + * California, Berkeley and its contributors.
1138 + * 4. Neither the name of the University nor the names of its contributors
1139 + * may be used to endorse or promote products derived from this software
1140 + * without specific prior written permission.
1142 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1143 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1144 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1145 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1146 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1147 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1148 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1149 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1150 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1151 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1154 + * @(#)tzfile.h 8.1 (Berkeley) 6/2/93
1161 + * Information about time zone files.
1163 + /* Time zone object file directory */
1164 +#define TZDIR "/usr/share/zoneinfo"
1165 +#define TZDEFAULT "/etc/localtime"
1166 +#define TZDEFRULES "posixrules"
1169 +** Each file begins with. . .
1173 + char tzh_reserved[24]; /* reserved for future use */
1174 + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
1175 + char tzh_leapcnt[4]; /* coded number of leap seconds */
1176 + char tzh_timecnt[4]; /* coded number of transition times */
1177 + char tzh_typecnt[4]; /* coded number of local time types */
1178 + char tzh_charcnt[4]; /* coded number of abbr. chars */
1182 +** . . .followed by. . .
1184 +** tzh_timecnt (char [4])s coded transition times a la time(2)
1185 +** tzh_timecnt (unsigned char)s types of local time starting at above
1186 +** tzh_typecnt repetitions of
1187 +** one (char [4]) coded GMT offset in seconds
1188 +** one (unsigned char) used to set tm_isdst
1189 +** one (unsigned char) that's an abbreviation list index
1190 +** tzh_charcnt (char)s '\0'-terminated zone abbreviations
1191 +** tzh_leapcnt repetitions of
1192 +** one (char [4]) coded leap second transition times
1193 +** one (char [4]) total correction after above
1194 +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
1195 +** time is standard time, if FALSE,
1196 +** transition time is wall clock time
1197 +** if absent, transition times are
1198 +** assumed to be wall clock time
1202 +** In the current implementation, "tzset()" refuses to deal with files that
1203 +** exceed any of the limits below.
1207 +** The TZ_MAX_TIMES value below is enough to handle a bit more than a
1208 +** year's worth of solar time (corrected daily to the nearest second) or
1209 +** 138 years of Pacific Presidential Election time
1210 +** (where there are three time zone transitions every fourth year).
1212 +#define TZ_MAX_TIMES 370
1214 +#define NOSOLAR /* 4BSD doesn't currently handle solar time */
1217 +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
1219 +#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
1222 +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
1224 +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
1226 +#define SECSPERMIN 60
1227 +#define MINSPERHOUR 60
1228 +#define HOURSPERDAY 24
1229 +#define DAYSPERWEEK 7
1230 +#define DAYSPERNYEAR 365
1231 +#define DAYSPERLYEAR 366
1232 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
1233 +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
1234 +#define MONSPERYEAR 12
1236 +#define TM_SUNDAY 0
1237 +#define TM_MONDAY 1
1238 +#define TM_TUESDAY 2
1239 +#define TM_WEDNESDAY 3
1240 +#define TM_THURSDAY 4
1241 +#define TM_FRIDAY 5
1242 +#define TM_SATURDAY 6
1244 +#define TM_JANUARY 0
1245 +#define TM_FEBRUARY 1
1251 +#define TM_AUGUST 7
1252 +#define TM_SEPTEMBER 8
1253 +#define TM_OCTOBER 9
1254 +#define TM_NOVEMBER 10
1255 +#define TM_DECEMBER 11
1257 +#define TM_YEAR_BASE 1900
1259 +#define EPOCH_YEAR 1970
1260 +#define EPOCH_WDAY TM_THURSDAY
1263 +** Accurate only for the past couple of centuries;
1264 +** that will probably do.
1267 +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
1269 +#endif /* !_TZFILE_H_ */
1271 +++ pax-20090728/vis.h
1273 +/* $OpenBSD: vis.h,v 1.11 2005/08/09 19:38:31 millert Exp $ */
1274 +/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
1277 + * Copyright (c) 1990 The Regents of the University of California.
1278 + * All rights reserved.
1280 + * Redistribution and use in source and binary forms, with or without
1281 + * modification, are permitted provided that the following conditions
1283 + * 1. Redistributions of source code must retain the above copyright
1284 + * notice, this list of conditions and the following disclaimer.
1285 + * 2. Redistributions in binary form must reproduce the above copyright
1286 + * notice, this list of conditions and the following disclaimer in the
1287 + * documentation and/or other materials provided with the distribution.
1288 + * 3. Neither the name of the University nor the names of its contributors
1289 + * may be used to endorse or promote products derived from this software
1290 + * without specific prior written permission.
1292 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1293 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1294 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1295 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1296 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1297 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1298 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1299 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1300 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1301 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1304 + * @(#)vis.h 5.9 (Berkeley) 4/3/91
1311 + * to select alternate encoding format
1313 +#define VIS_OCTAL 0x01 /* use octal \ddd format */
1314 +#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
1317 + * to alter set of characters encoded (default is to encode all
1318 + * non-graphic except space, tab, and newline).
1320 +#define VIS_SP 0x04 /* also encode space */
1321 +#define VIS_TAB 0x08 /* also encode tab */
1322 +#define VIS_NL 0x10 /* also encode newline */
1323 +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
1324 +#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
1329 +#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
1330 +#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */
1333 + * unvis return codes
1335 +#define UNVIS_VALID 1 /* character valid */
1336 +#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
1337 +#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
1338 +#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
1339 +#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
1344 +#define UNVIS_END 1 /* no more characters */
1346 +#include <sys/cdefs.h>
1349 +char *vis(char *, int, int, int);
1350 +int strvis(char *, const char *, int);
1351 +int strnvis(char *, const char *, size_t, int)
1352 + __attribute__ ((__bounded__(__string__,1,3)));
1353 +int strvisx(char *, const char *, size_t, int)
1354 + __attribute__ ((__bounded__(__string__,1,3)));
1355 +int strunvis(char *, const char *);
1356 +int unvis(char *, char, int *, int);
1357 +ssize_t strnunvis(char *, const char *, size_t)
1358 + __attribute__ ((__bounded__(__string__,1,3)));
1362 +#endif /* !_VIS_H_ */
1364 +++ pax-20090728/fgetln.h
1366 +/* fgetline: Read one line of input and return a pointer to
1367 + that line. Necessary space is obtained from malloc.
1368 + (char *) NULL is returned on EOF.
1370 + Andy Dougherty doughera@lafcol.lafayette.edu
1372 + Lafayette College, Easton PA 18042
1374 + This fgetline implementation was written by Andrew Dougherty
1375 + <doughera@lafayette.edu>. I hearby place it in the public domain.
1376 + As a courtesy, please leave my name attached to the source.
1378 + This code comes with no warranty whatsoever, and I take no
1379 + responsibility for any consequences of its use.
1382 +char *fgetln(FILE *fp, size_t *length);
1383 --- pax-20090728.orig/options.c
1384 +++ pax-20090728/options.c
1385 @@ -60,6 +60,8 @@ static const char rcsid[] = "$OpenBSD: o
1389 +#include "fgetln.h" /* added, David */
1392 * Routines which handle command line options
1394 @@ -72,7 +74,7 @@ static int no_op(void);
1395 static void printflg(unsigned int);
1396 static int c_frmt(const void *, const void *);
1397 static off_t str_offt(char *);
1398 -static char *getline(FILE *fp);
1399 +static char *bsd_getline(FILE *fp);
1400 static void pax_options(int, char **);
1401 static void pax_usage(void);
1402 static void tar_options(int, char **);
1403 @@ -882,7 +884,7 @@ tar_options(int argc, char **argv)
1404 paxwarn(1, "Unable to open file '%s' for read", file);
1407 - while ((str = getline(fp)) != NULL) {
1408 + while ((str = bsd_getline(fp)) != NULL) {
1409 if (pat_add(str, dir) < 0)
1412 @@ -961,7 +963,7 @@ tar_options(int argc, char **argv)
1413 paxwarn(1, "Unable to open file '%s' for read", file);
1416 - while ((str = getline(fp)) != NULL) {
1417 + while ((str = bsd_getline(fp)) != NULL) {
1418 if (ftree_add(str, 0) < 0)
1421 @@ -1183,7 +1185,7 @@ cpio_options(int argc, char **argv)
1422 paxwarn(1, "Unable to open file '%s' for read", optarg);
1425 - while ((str = getline(fp)) != NULL) {
1426 + while ((str = bsd_getline(fp)) != NULL) {
1430 @@ -1282,7 +1284,7 @@ cpio_options(int argc, char **argv)
1431 * no read errors allowed on updates/append operation!
1434 - while ((str = getline(stdin)) != NULL) {
1435 + while ((str = bsd_getline(stdin)) != NULL) {
1438 if (getline_error) {
1439 @@ -1459,7 +1461,7 @@ str_offt(char *val)
1440 if ((num == LONG_MAX) || (num <= 0) || (expr == val))
1442 num = strtoq(val, &expr, 0);
1443 - if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
1444 + if ((num == LLONG_MAX) || (num <= 0) || (expr == val))
1448 @@ -1511,7 +1513,7 @@ str_offt(char *val)
1453 +bsd_getline(FILE *f)