clean up the diff
[debian/pax] / debian / patches / lump-debian-diffs
1 --- pax-20090728.orig/pax.c
2 +++ pax-20090728/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) */
11  
12 @@ -235,6 +235,12 @@ main(int argc, char **argv)
13         char *tmpdir;
14         size_t tdlen;
15  
16 +       /* 
17 +        * On some systems, stderr is not a constant, so we initialize listf
18 +        * immediately to emulate the behavior.
19 +        */
20 +       listf=stderr;
21 +
22         /*
23          * Keep a reference to cwd, so we can always come back home.
24          */
25 --- pax-20090728.orig/ar_subs.c
26 +++ pax-20090728/ar_subs.c
27 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: a
28  
29  #include <sys/types.h>
30  #include <sys/time.h>
31 +#include <time.h>
32  #include <sys/stat.h>
33  #include <sys/param.h>
34  #include <signal.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
39          */
40         if (!pwopn) {
41 +#ifdef DEBIAN
42 +               setpwent();
43 +#else
44                 setpassent(1);
45 +#endif
46                 ++pwopn;
47         }
48         if (ptr == NULL)
49 @@ -266,7 +270,11 @@ name_gid(gid_t gid, int frc)
50          * No entry for this gid, we will add it
51          */
52         if (!gropn) {
53 +#ifdef DEBIAN
54 +               setgrent();
55 +#else
56                 setgroupent(1);
57 +#endif
58                 ++gropn;
59         }
60         if (ptr == NULL)
61 @@ -333,7 +341,11 @@ uid_name(char *name, uid_t *uid)
62         }
63  
64         if (!pwopn) {
65 +#ifdef DEBIAN
66 +               setpwent();
67 +#else
68                 setpassent(1);
69 +#endif
70                 ++pwopn;
71         }
72  
73 @@ -396,7 +408,11 @@ gid_name(char *name, gid_t *gid)
74         }
75  
76         if (!gropn) {
77 +#ifdef DEBIAN
78 +               setgrent();
79 +#else
80                 setgroupent(1);
81 +#endif
82                 ++gropn;
83         }
84         if (ptr == NULL)
85 --- pax-20090728.orig/pax.h
86 +++ pax-20090728/pax.h
87 @@ -242,3 +242,8 @@ typedef struct oplist {
88  #define OCT            8
89  #define _PAX_          1
90  #define _TFILE_BASE    "paxXXXXXXXXXX"
91 +
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);
95 +
96 --- pax-20090728.orig/sel_subs.c
97 +++ pax-20090728/sel_subs.c
98 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: s
99  
100  #include <sys/types.h>
101  #include <sys/time.h>
102 +#include <time.h>
103  #include <sys/stat.h>
104  #include <sys/param.h>
105  #include <ctype.h>
106 @@ -52,12 +53,14 @@ static const char rcsid[] = "$OpenBSD: s
107  #include <stdio.h>
108  #include <stdlib.h>
109  #include <string.h>
110 -#include <tzfile.h>
111 +#include <time.h>
112  #include <unistd.h>
113  #include "pax.h"
114  #include "sel_subs.h"
115  #include "extern.h"
116  
117 +#define TM_YEAR_BASE 1900
118 +
119  static int str_sec(const char *, time_t *);
120  static int usr_match(ARCHD *);
121  static int grp_match(ARCHD *);
122 --- /dev/null
123 +++ pax-20090728/types.h
124 @@ -0,0 +1,169 @@
125 +/*-
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.
133 + *
134 + * Redistribution and use in source and binary forms, with or without
135 + * modification, are permitted provided that the following conditions
136 + * are met:
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.
149 + *
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
160 + * SUCH DAMAGE.
161 + *
162 + *     @(#)types.h     8.4 (Berkeley) 1/21/94
163 + * $Id: types.h,v 1.1 2001-07-23 05:20:01 bdale Exp $
164 + */
165 +
166 +#ifndef _SYS_TYPES_H_
167 +#define        _SYS_TYPES_H_
168 +
169 +#include <sys/cdefs.h>
170 +
171 +/* Machine type dependent parameters. */
172 +#include <machine/endian.h>
173 +
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 */
181 +#endif
182 +
183 +typedef        unsigned long long u_quad_t;    /* quads */
184 +typedef        long long       quad_t;
185 +typedef        quad_t *        qaddr_t;
186 +
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 */
200 +
201 +/*
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.
205 + */
206 +#ifndef KERNEL
207 +__BEGIN_DECLS
208 +off_t   lseek __P((int, off_t, int));
209 +__END_DECLS
210 +#endif
211 +
212 +#ifndef _POSIX_SOURCE
213 +/*
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.
217 + */
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 */
221 +#endif
222 +
223 +#include <machine/ansi.h>
224 +#include <machine/types.h>
225 +
226 +#ifdef _BSD_CLOCK_T_
227 +typedef        _BSD_CLOCK_T_   clock_t;
228 +#undef _BSD_CLOCK_T_
229 +#endif
230 +
231 +#ifdef _BSD_SIZE_T_
232 +typedef        _BSD_SIZE_T_    size_t;
233 +#undef _BSD_SIZE_T_
234 +#endif
235 +
236 +#ifdef _BSD_SSIZE_T_
237 +typedef        _BSD_SSIZE_T_   ssize_t;
238 +#undef _BSD_SSIZE_T_
239 +#endif
240 +
241 +#ifdef _BSD_TIME_T_
242 +typedef        _BSD_TIME_T_    time_t;
243 +#undef _BSD_TIME_T_
244 +#endif
245 +
246 +#ifndef _POSIX_SOURCE
247 +#define        NBBY    8               /* number of bits in a byte */
248 +
249 +/*
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.
254 + */
255 +#ifndef        FD_SETSIZE
256 +#define        FD_SETSIZE      256
257 +#endif
258 +
259 +typedef long   fd_mask;
260 +#define NFDBITS        (sizeof(fd_mask) * NBBY)        /* bits per mask */
261 +
262 +#ifndef howmany
263 +#define        howmany(x, y)   (((x)+((y)-1))/(y))
264 +#endif
265 +
266 +typedef        struct fd_set {
267 +       fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
268 +} fd_set;
269 +
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)))
275 +
276 +#if defined(__STDC__) && defined(KERNEL)
277 +/*
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.
281 + */
282 +struct proc;
283 +struct pgrp;
284 +struct ucred;
285 +struct rusage;
286 +struct file;
287 +struct buf;
288 +struct tty;
289 +struct uio;
290 +#endif
291 +
292 +#endif /* !_POSIX_SOURCE */
293 +#endif /* !_SYS_TYPES_H_ */
294 --- /dev/null
295 +++ pax-20090728/strmode.h
296 @@ -0,0 +1,34 @@
297 +/*-
298 + * Copyright (c) 1990, 1993
299 + *     The Regents of the University of California.  All rights reserved.
300 + *
301 + * Redistribution and use in source and binary forms, with or without
302 + * modification, are permitted provided that the following conditions
303 + * are met:
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.
316 + *
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
327 + * SUCH DAMAGE.
328 + */
329 +
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 */
335  
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)
342         /*
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.
345 +        *
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.
351          */
352         dest = arcn->name;
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));
357  
358 +       /*
359 +        * Always add devmajor and devminor
360 +        */
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))
365 +               goto out;
366 +
367         /*
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
370 --- /dev/null
371 +++ pax-20090728/strmode.c
372 @@ -0,0 +1,147 @@
373 +/*-
374 + * Copyright (c) 1990, 1993
375 + *     The Regents of the University of California.  All rights reserved.
376 + *
377 + * Redistribution and use in source and binary forms, with or without
378 + * modification, are permitted provided that the following conditions
379 + * are met:
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.
392 + *
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
403 + * SUCH DAMAGE.
404 + */
405 +
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 */
409 +
410 +#include <sys/types.h>
411 +#include <sys/stat.h>
412 +#include <string.h>
413 +
414 +void
415 +strmode(mode, p)
416 +       register mode_t mode;
417 +       register char *p;
418 +{
419 +        /* print type */
420 +       switch (mode & S_IFMT) {
421 +       case S_IFDIR:                   /* directory */
422 +               *p++ = 'd';
423 +               break;
424 +       case S_IFCHR:                   /* character special */
425 +               *p++ = 'c';
426 +               break;
427 +       case S_IFBLK:                   /* block special */
428 +               *p++ = 'b';
429 +               break;
430 +       case S_IFREG:                   /* regular */
431 +               *p++ = '-';
432 +               break;
433 +       case S_IFLNK:                   /* symbolic link */
434 +               *p++ = 'l';
435 +               break;
436 +       case S_IFSOCK:                  /* socket */
437 +               *p++ = 's';
438 +               break;
439 +#ifdef S_IFIFO
440 +       case S_IFIFO:                   /* fifo */
441 +               *p++ = 'p';
442 +               break;
443 +#endif
444 +       default:                        /* unknown */
445 +               *p++ = '?';
446 +               break;
447 +       }
448 +       /* usr */
449 +       if (mode & S_IRUSR)
450 +               *p++ = 'r';
451 +       else
452 +               *p++ = '-';
453 +       if (mode & S_IWUSR)
454 +               *p++ = 'w';
455 +       else
456 +               *p++ = '-';
457 +       switch (mode & (S_IXUSR | S_ISUID)) {
458 +       case 0:
459 +               *p++ = '-';
460 +               break;
461 +       case S_IXUSR:
462 +               *p++ = 'x';
463 +               break;
464 +       case S_ISUID:
465 +               *p++ = 'S';
466 +               break;
467 +       case S_IXUSR | S_ISUID:
468 +               *p++ = 's';
469 +               break;
470 +       }
471 +       /* group */
472 +       if (mode & S_IRGRP)
473 +               *p++ = 'r';
474 +       else
475 +               *p++ = '-';
476 +       if (mode & S_IWGRP)
477 +               *p++ = 'w';
478 +       else
479 +               *p++ = '-';
480 +       switch (mode & (S_IXGRP | S_ISGID)) {
481 +       case 0:
482 +               *p++ = '-';
483 +               break;
484 +       case S_IXGRP:
485 +               *p++ = 'x';
486 +               break;
487 +       case S_ISGID:
488 +               *p++ = 'S';
489 +               break;
490 +       case S_IXGRP | S_ISGID:
491 +               *p++ = 's';
492 +               break;
493 +       }
494 +       /* other */
495 +       if (mode & S_IROTH)
496 +               *p++ = 'r';
497 +       else
498 +               *p++ = '-';
499 +       if (mode & S_IWOTH)
500 +               *p++ = 'w';
501 +       else
502 +               *p++ = '-';
503 +       switch (mode & (S_IXOTH | S_ISVTX)) {
504 +       case 0:
505 +               *p++ = '-';
506 +               break;
507 +       case S_IXOTH:
508 +               *p++ = 'x';
509 +               break;
510 +       case S_ISVTX:
511 +               *p++ = 'T';
512 +               break;
513 +       case S_IXOTH | S_ISVTX:
514 +               *p++ = 't';
515 +               break;
516 +       }
517 +       *p++ = ' ';             /* will be a '+' if ACL's implemented */
518 +       *p = '\0';
519 +}
520 --- pax-20090728.orig/Makefile
521 +++ pax-20090728/Makefile
522 @@ -14,8 +14,25 @@
523  PROG=   pax
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\
526 -       tar.c tty_subs.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
530 +OBJS=  $(SRCS:.c=.o)
531 +MAN=   pax.1
532  
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
536 +
537 +prefix=/usr
538 +
539 +pax:   $(OBJS)
540 +       $(CC) $(CFLAGS) $(OBJS) -o $@ $(LIBS)
541 +
542 +clean:
543 +       $(RM) *.o
544 +
545 +realclean: clean
546 +       $(RM) $(PROG)
547 +
548 +install:
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
552 --- /dev/null
553 +++ pax-20090728/strlcpy.c
554 @@ -0,0 +1,51 @@
555 +/*     $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $    */
556 +
557 +/*
558 + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
559 + *
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.
563 + *
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.
571 + */
572 +
573 +#include <sys/types.h>
574 +#include <string.h>
575 +
576 +/*
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.
580 + */
581 +size_t
582 +strlcpy(char *dst, const char *src, size_t siz)
583 +{
584 +       char *d = dst;
585 +       const char *s = src;
586 +       size_t n = siz;
587 +
588 +       /* Copy as many bytes as will fit */
589 +       if (n != 0) {
590 +               while (--n != 0) {
591 +                       if ((*d++ = *s++) == '\0')
592 +                               break;
593 +               }
594 +       }
595 +
596 +       /* Not enough room in dst, add NUL and traverse rest of src */
597 +       if (n == 0) {
598 +               if (siz != 0)
599 +                       *d = '\0';              /* NUL-terminate dst */
600 +               while (*s++)
601 +                       ;
602 +       }
603 +
604 +       return(s - src - 1);    /* count does not include NUL */
605 +}
606 --- pax-20090728.orig/ar_io.c
607 +++ pax-20090728/ar_io.c
608 @@ -1248,8 +1248,9 @@ ar_next(void)
609  
610  /*
611   * ar_start_gzip()
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
616 + * (parent).
617   */
618  void
619  ar_start_gzip(int fd, const char *gzip_program, int wr)
620 --- /dev/null
621 +++ pax-20090728/Makefile.bsd
622 @@ -0,0 +1,34 @@
623 +#      $OpenBSD: Makefile,v 1.9 1997/09/21 11:35:28 deraadt Exp $
624 +
625 +# To install on versions prior to BSD 4.4 the following may have to be
626 +# defined with CFLAGS +=
627 +#
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
635 +#              NOT RUN PROPERLY.
636 +#
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.
641 +#
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.
648 +
649 +PROG=   pax
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\
652 +       tar.c tty_subs.c
653 +MAN=   pax.1 tar.1 cpio.1
654 +LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
655 +
656 +.include <bsd.prog.mk>
657 --- /dev/null
658 +++ pax-20090728/vis.c
659 @@ -0,0 +1,219 @@
660 +/*     $OpenBSD: vis.c,v 1.19 2005/09/01 17:15:49 millert Exp $ */
661 +/*-
662 + * Copyright (c) 1989, 1993
663 + *     The Regents of the University of California.  All rights reserved.
664 + *
665 + * Redistribution and use in source and binary forms, with or without
666 + * modification, are permitted provided that the following conditions
667 + * are met:
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.
676 + *
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
687 + * SUCH DAMAGE.
688 + */
689 +
690 +#include <sys/types.h>
691 +#include <limits.h>
692 +#include <ctype.h>
693 +#include <string.h>
694 +#include "vis.h"
695 +
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)))))
707 +
708 +/*
709 + * vis - visually encode characters
710 + */
711 +char *
712 +vis(char *dst, int c, int flag, int nextc)
713 +{
714 +       if (isvisible(c)) {
715 +               *dst++ = c;
716 +               if (c == '\\' && (flag & VIS_NOSLASH) == 0)
717 +                       *dst++ = '\\';
718 +               *dst = '\0';
719 +               return (dst);
720 +       }
721 +
722 +       if (flag & VIS_CSTYLE) {
723 +               switch(c) {
724 +               case '\n':
725 +                       *dst++ = '\\';
726 +                       *dst++ = 'n';
727 +                       goto done;
728 +               case '\r':
729 +                       *dst++ = '\\';
730 +                       *dst++ = 'r';
731 +                       goto done;
732 +               case '\b':
733 +                       *dst++ = '\\';
734 +                       *dst++ = 'b';
735 +                       goto done;
736 +               case '\a':
737 +                       *dst++ = '\\';
738 +                       *dst++ = 'a';
739 +                       goto done;
740 +               case '\v':
741 +                       *dst++ = '\\';
742 +                       *dst++ = 'v';
743 +                       goto done;
744 +               case '\t':
745 +                       *dst++ = '\\';
746 +                       *dst++ = 't';
747 +                       goto done;
748 +               case '\f':
749 +                       *dst++ = '\\';
750 +                       *dst++ = 'f';
751 +                       goto done;
752 +               case ' ':
753 +                       *dst++ = '\\';
754 +                       *dst++ = 's';
755 +                       goto done;
756 +               case '\0':
757 +                       *dst++ = '\\';
758 +                       *dst++ = '0';
759 +                       if (isoctal(nextc)) {
760 +                               *dst++ = '0';
761 +                               *dst++ = '0';
762 +                       }
763 +                       goto done;
764 +               }
765 +       }
766 +       if (((c & 0177) == ' ') || (flag & VIS_OCTAL) ||
767 +           ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) {
768 +               *dst++ = '\\';
769 +               *dst++ = ((u_char)c >> 6 & 07) + '0';
770 +               *dst++ = ((u_char)c >> 3 & 07) + '0';
771 +               *dst++ = ((u_char)c & 07) + '0';
772 +               goto done;
773 +       }
774 +       if ((flag & VIS_NOSLASH) == 0)
775 +               *dst++ = '\\';
776 +       if (c & 0200) {
777 +               c &= 0177;
778 +               *dst++ = 'M';
779 +       }
780 +       if (iscntrl((u_char)c)) {
781 +               *dst++ = '^';
782 +               if (c == 0177)
783 +                       *dst++ = '?';
784 +               else
785 +                       *dst++ = c + '@';
786 +       } else {
787 +               *dst++ = '-';
788 +               *dst++ = c;
789 +       }
790 +done:
791 +       *dst = '\0';
792 +       return (dst);
793 +}
794 +
795 +/*
796 + * strvis, strnvis, strvisx - visually encode characters from src into dst
797 + *     
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,
800 + *     is returned. 
801 + *
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.
804 + *
805 + *     Strvisx encodes exactly len bytes from src into dst.
806 + *     This is useful for encoding a block of data.
807 + */
808 +int
809 +strvis(char *dst, const char *src, int flag)
810 +{
811 +       char c;
812 +       char *start;
813 +
814 +       for (start = dst; (c = *src);)
815 +               dst = vis(dst, c, flag, *++src);
816 +       *dst = '\0';
817 +       return (dst - start);
818 +}
819 +
820 +int
821 +strnvis(char *dst, const char *src, size_t siz, int flag)
822 +{
823 +       char *start, *end;
824 +       char tbuf[5];
825 +       int c, i;
826 +
827 +       i = 0;
828 +       for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) {
829 +               if (isvisible(c)) {
830 +                       i = 1;
831 +                       *dst++ = c;
832 +                       if (c == '\\' && (flag & VIS_NOSLASH) == 0) {
833 +                               /* need space for the extra '\\' */
834 +                               if (dst < end)
835 +                                       *dst++ = '\\';
836 +                               else {
837 +                                       dst--;
838 +                                       i = 2;
839 +                                       break;
840 +                               }
841 +                       }
842 +                       src++;
843 +               } else {
844 +                       i = vis(tbuf, c, flag, *++src) - tbuf;
845 +                       if (dst + i <= end) {
846 +                               memcpy(dst, tbuf, i);
847 +                               dst += i;
848 +                       } else {
849 +                               src--;
850 +                               break;
851 +                       }
852 +               }
853 +       }
854 +       if (siz > 0)
855 +               *dst = '\0';
856 +       if (dst + i > end) {
857 +               /* adjust return value for truncation */
858 +               while ((c = *src))
859 +                       dst += vis(tbuf, c, flag, *++src) - tbuf;
860 +       }
861 +       return (dst - start);
862 +}
863 +
864 +int
865 +strvisx(char *dst, const char *src, size_t len, int flag)
866 +{
867 +       char c;
868 +       char *start;
869 +
870 +       for (start = dst; len > 1; len--) {
871 +               c = *src;
872 +               dst = vis(dst, c, flag, *++src);
873 +       }
874 +       if (len)
875 +               dst = vis(dst, *src, flag, '\0');
876 +       *dst = '\0';
877 +       return (dst - start);
878 +}
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 */
883  
884  #include <sys/types.h>
885 +#include <sys/sysmacros.h>
886  #include <sys/time.h>
887 +#include <time.h>
888  #include <sys/stat.h>
889  #include <sys/param.h>
890  #include <stdio.h>
891 -#include <tzfile.h>
892 +#include "tzfile.h"
893  #include <utmp.h>
894  #include <unistd.h>
895  #include <stdlib.h>
896  #include <string.h>
897 -#include <vis.h>
898 +#include "vis.h"
899  #include "pax.h"
900  #include "extern.h"
901  
902 +#include "strmode.h"
903 +
904  /*
905   * a collection of general purpose subroutines used by pax
906   */
907 @@ -65,6 +69,9 @@ static const char rcsid[] = "$OpenBSD: g
908   */
909  #define MODELEN 20
910  #define DATELEN 64
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)
918         /*
919          * if printing to a tty, use vis(3) to print special characters.
920          */
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
929  The
930  .Nm
931  utility is compliant with the
932 -.St -p1003.1-2008
933 +POSIX 1003.1-2008
934  specification.
935  .Pp
936  The flags
937 --- /dev/null
938 +++ pax-20090728/fgetln.c
939 @@ -0,0 +1,134 @@
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.
943 +
944 +    Andy Dougherty             doughera@lafcol.lafayette.edu
945 +    Dept. of Physics
946 +    Lafayette College, Easton PA 18042
947 +
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):
951 +
952 +       tmp = fgetline(fp);
953 +       ntmp = Ealloc(strlen(tmp)+1, sizeof(char));  
954 +       strncpy(ntmp, tmp, strlen(tmp)+1);
955 +
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.
959 +
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.)
964 +
965 + * Version 1.0  A. Dougherty  2/27/91
966 +
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.
970 +
971 + This code comes with no warranty whatsoever, and I take no
972 + responsibility for any consequences of its use.
973 +*/
974 +
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
978 +   malloc().
979 +
980 +   Aside:  We have computed strlen(buf) in this function.  It
981 +   seems a shame to throw it away.
982 +*/
983 +
984 +#include <stdio.h>
985 +#include <stdlib.h>
986 +#include <sys/types.h>
987 +
988 +#define LINELEN 128 /* A decent guess that should only rarely be
989 +                       overwritten.
990 +                   */
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.
994 +                       */
995 +
996 +void *Emalloc(size_t len) /* David */
997 +{
998 +       char *p;
999 +
1000 +       p=malloc(len);
1001 +       if (p == NULL) {
1002 +               perror("out of memory (Emalloc)");
1003 +               exit(2);
1004 +
1005 +       }
1006 +       return p;
1007 +}
1008 +
1009 +void *Erealloc(char *p, size_t len) /* David */
1010 +{
1011 +       p=realloc(p, len);
1012 +       if (p == NULL) {
1013 +               perror("out of memory (Erealloc)");
1014 +               exit(2);
1015 +
1016 +       }
1017 +       return p;
1018 +}
1019 +
1020 +char *
1021 +fgetln(FILE *fp, size_t *length)
1022 +  {
1023 +    static char *buf = NULL;
1024 +    static size_t avail = 0;
1025 +    int c;
1026 +    char *p; /* Temporary used for reducing length. */
1027 +    int len;
1028 +
1029 +    if (avail == 0)
1030 +      {
1031 +       buf = (char *) Emalloc(LINELEN * sizeof(char));
1032 +       avail = LINELEN;
1033 +      }
1034 +
1035 +    len = 0; /* Current length */
1036 +
1037 +    while ((c=getc(fp)) != EOF)
1038 +      {
1039 +       if (len >= avail) /* Need to ask for space */
1040 +         {
1041 +           avail += LINELEN;  /* Maybe avail *= 2 would be better */
1042 +           buf = (char *) Erealloc((void *) buf, avail * sizeof(char));
1043 +         }
1044 +       buf[len] = c;
1045 +       len++;
1046 +       if (c == '\n')
1047 +           break;
1048 +      }
1049 +
1050 +    if (c == EOF && len == 0)
1051 +       return (char *) NULL;
1052 +
1053 +    /* Add terminating '\0' character */
1054 +    if (len >= avail)  /* Need 1 more space */
1055 +       buf = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1056 +    buf[len] = '\0';
1057 +
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.)
1061 +    */
1062 +    if (avail - len  > OK_TO_WASTE)
1063 +      {
1064 +       p = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1065 +       if (p != NULL)
1066 +         {
1067 +           buf = p;
1068 +           avail = len + 1;
1069 +         }
1070 +      }
1071 +    *length=len-1;
1072 +    return buf;
1073 +  }
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 */
1078  
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>
1084 --- /dev/null
1085 +++ pax-20090728/tzfile.h
1086 @@ -0,0 +1,158 @@
1087 +/*
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
1091 + *
1092 + */
1093 +
1094 +/*
1095 + * Copyright (c) 1988, 1993
1096 + *     The Regents of the University of California.  All rights reserved.
1097 + *
1098 + * This code is derived from software contributed to Berkeley by
1099 + * Arthur David Olson of the National Cancer Institute.
1100 + *
1101 + * Redistribution and use in source and binary forms, with or without
1102 + * modification, are permitted provided that the following conditions
1103 + * are met:
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.
1116 + *
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
1127 + * SUCH DAMAGE.
1128 + *
1129 + *     @(#)tzfile.h    8.1 (Berkeley) 6/2/93
1130 + */
1131 +
1132 +#ifndef _TZFILE_H_
1133 +#define        _TZFILE_H_
1134 +
1135 +/*
1136 + * Information about time zone files.
1137 + */
1138 +                       /* Time zone object file directory */
1139 +#define TZDIR          "/usr/share/zoneinfo"
1140 +#define TZDEFAULT      "/etc/localtime"
1141 +#define TZDEFRULES     "posixrules"
1142 +
1143 +/*
1144 +** Each file begins with. . .
1145 +*/
1146 +
1147 +struct tzhead {
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 */
1154 +};
1155 +
1156 +/*
1157 +** . . .followed by. . .
1158 +**
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
1174 +*/
1175 +
1176 +/*
1177 +** In the current implementation, "tzset()" refuses to deal with files that
1178 +** exceed any of the limits below.
1179 +*/
1180 +
1181 +/*
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).
1186 +*/
1187 +#define TZ_MAX_TIMES   370
1188 +
1189 +#define NOSOLAR                        /* 4BSD doesn't currently handle solar time */
1190 +
1191 +#ifndef NOSOLAR
1192 +#define TZ_MAX_TYPES   256     /* Limited by what (unsigned char)'s can hold */
1193 +#else
1194 +#define TZ_MAX_TYPES   10      /* Maximum number of local time types */
1195 +#endif
1196 +
1197 +#define TZ_MAX_CHARS   50      /* Maximum number of abbreviation characters */
1198 +
1199 +#define        TZ_MAX_LEAPS    50      /* Maximum number of leap second corrections */
1200 +
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
1210 +
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
1218 +
1219 +#define TM_JANUARY     0
1220 +#define TM_FEBRUARY    1
1221 +#define TM_MARCH       2
1222 +#define TM_APRIL       3
1223 +#define TM_MAY         4
1224 +#define TM_JUNE                5
1225 +#define TM_JULY                6
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
1231 +
1232 +#define TM_YEAR_BASE   1900
1233 +
1234 +#define EPOCH_YEAR     1970
1235 +#define EPOCH_WDAY     TM_THURSDAY
1236 +
1237 +/*
1238 +** Accurate only for the past couple of centuries;
1239 +** that will probably do.
1240 +*/
1241 +
1242 +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
1243 +
1244 +#endif /* !_TZFILE_H_ */
1245 --- /dev/null
1246 +++ pax-20090728/vis.h
1247 @@ -0,0 +1,90 @@
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 $      */
1250 +
1251 +/*-
1252 + * Copyright (c) 1990 The Regents of the University of California.
1253 + * All rights reserved.
1254 + *
1255 + * Redistribution and use in source and binary forms, with or without
1256 + * modification, are permitted provided that the following conditions
1257 + * are met:
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.
1266 + *
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
1277 + * SUCH DAMAGE.
1278 + *
1279 + *     @(#)vis.h       5.9 (Berkeley) 4/3/91
1280 + */
1281 +
1282 +#ifndef _VIS_H_
1283 +#define        _VIS_H_
1284 +
1285 +/*
1286 + * to select alternate encoding format
1287 + */
1288 +#define        VIS_OCTAL       0x01    /* use octal \ddd format */
1289 +#define        VIS_CSTYLE      0x02    /* use \[nrft0..] where appropriate */
1290 +
1291 +/*
1292 + * to alter set of characters encoded (default is to encode all
1293 + * non-graphic except space, tab, and newline).
1294 + */
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 */
1300 +
1301 +/*
1302 + * other
1303 + */
1304 +#define        VIS_NOSLASH     0x40    /* inhibit printing '\' */
1305 +#define        VIS_GLOB        0x100   /* encode glob(3) magics and '#' */
1306 +
1307 +/*
1308 + * unvis return codes
1309 + */
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) */
1315 +
1316 +/*
1317 + * unvis flags
1318 + */
1319 +#define        UNVIS_END       1       /* no more characters */
1320 +
1321 +#include <sys/cdefs.h>
1322 +
1323 +__BEGIN_DECLS
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)));
1334 +
1335 +__END_DECLS
1336 +
1337 +#endif /* !_VIS_H_ */
1338 --- /dev/null
1339 +++ pax-20090728/fgetln.h
1340 @@ -0,0 +1,17 @@
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.
1344 +
1345 +    Andy Dougherty             doughera@lafcol.lafayette.edu
1346 +    Dept. of Physics
1347 +    Lafayette College, Easton PA 18042
1348 +
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.
1352 +
1353 +    This code comes with no warranty whatsoever, and I take no
1354 +    responsibility for any consequences of its use.
1355 +*/
1356 +
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
1361  #include "tar.h"
1362  #include "extern.h"
1363  
1364 +#include "fgetln.h"    /* added, David */
1365 +
1366  /*
1367   * Routines which handle command line options
1368   */
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);
1380                                                 tar_usage();
1381                                         }
1382 -                                       while ((str = getline(fp)) != NULL) {
1383 +                                       while ((str = bsd_getline(fp)) != NULL) {
1384                                                 if (pat_add(str, dir) < 0)
1385                                                         tar_usage();
1386                                                 sawpat = 1;
1387 @@ -961,7 +963,7 @@ tar_options(int argc, char **argv)
1388                                         paxwarn(1, "Unable to open file '%s' for read", file);
1389                                         tar_usage();
1390                                 }
1391 -                               while ((str = getline(fp)) != NULL) {
1392 +                               while ((str = bsd_getline(fp)) != NULL) {
1393                                         if (ftree_add(str, 0) < 0)
1394                                                 tar_usage();
1395                                 }
1396 @@ -1183,7 +1185,7 @@ cpio_options(int argc, char **argv)
1397                                         paxwarn(1, "Unable to open file '%s' for read", optarg);
1398                                         cpio_usage();
1399                                 }
1400 -                               while ((str = getline(fp)) != NULL) {
1401 +                               while ((str = bsd_getline(fp)) != NULL) {
1402                                         pat_add(str, NULL);
1403                                 }
1404                                 fclose(fp);
1405 @@ -1282,7 +1284,7 @@ cpio_options(int argc, char **argv)
1406                          * no read errors allowed on updates/append operation!
1407                          */
1408                         maxflt = 0;
1409 -                       while ((str = getline(stdin)) != NULL) {
1410 +                       while ((str = bsd_getline(stdin)) != NULL) {
1411                                 ftree_add(str, 0);
1412                         }
1413                         if (getline_error) {
1414 @@ -1459,7 +1461,7 @@ str_offt(char *val)
1415         if ((num == LONG_MAX) || (num <= 0) || (expr == val))
1416  #      else
1417         num = strtoq(val, &expr, 0);
1418 -       if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
1419 +       if ((num == LLONG_MAX) || (num <= 0) || (expr == val))
1420  #      endif
1421                 return(0);
1422  
1423 @@ -1511,7 +1513,7 @@ str_offt(char *val)
1424  }
1425  
1426  char *
1427 -getline(FILE *f)
1428 +bsd_getline(FILE *f)
1429  {
1430         char *name, *temp;
1431         size_t len;