X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Flist.c;h=a3b38304c9368a430515f8f1050d2ed9bbbb76fc;hb=00a2b4708fc77a09c9b5ca372b2846341c12c75e;hp=2eba9f651fb8a650db9a43d511c414b938a72169;hpb=d1f1e3a18997f3357fe946750d13ab0ce2cc21ef;p=chaz%2Ftar diff --git a/src/list.c b/src/list.c index 2eba9f6..a3b3830 100644 --- a/src/list.c +++ b/src/list.c @@ -1,5 +1,5 @@ /* List a tar archive, with support routines for reading a tar archive. - Copyright (C) 1988, 92, 93, 94, 96, 97 Free Software Foundation, Inc. + Copyright 1988,92,93,94,96,97,98,1999 Free Software Foundation, Inc. Written by John Gilmore, on 1985-08-26. This program is free software; you can redistribute it and/or modify it @@ -415,9 +415,28 @@ read_header (void) } else { - assign_string (¤t_file_name, - (next_long_name ? next_long_name - : current_header->header.name)); + char *name = next_long_name; + struct posix_header *h = ¤t_header->header; + char namebuf[sizeof h->prefix + 1 + sizeof h->name + 1]; + + if (! name) + { + /* Accept file names as specified by POSIX.1-1996 + section 10.1.1. */ + char *np = namebuf; + if (h->prefix[0]) + { + memcpy (np, h->prefix, sizeof h->prefix); + np[sizeof h->prefix] = '\0'; + np += strlen (np); + *np++ = '/'; + } + memcpy (np, h->name, sizeof h->name); + np[sizeof h->name] = '\0'; + name = namebuf; + } + + assign_string (¤t_file_name, name); assign_string (¤t_link_name, (next_long_link ? next_long_link : current_header->header.linkname)); @@ -568,47 +587,47 @@ from_oct (const char *where0, size_t digs0, const char *type, uintmax_t maxval) gid_t gid_from_oct (const char *p, size_t s) { - return from_oct (p, s, "gid_t", GID_MAX); + return from_oct (p, s, "gid_t", (uintmax_t) TYPE_MAXIMUM (gid_t)); } major_t major_from_oct (const char *p, size_t s) { - return from_oct (p, s, "major_t", MAJOR_MAX); + return from_oct (p, s, "major_t", (uintmax_t) TYPE_MAXIMUM (major_t)); } minor_t minor_from_oct (const char *p, size_t s) { - return from_oct (p, s, "minor_t", MINOR_MAX); + return from_oct (p, s, "minor_t", (uintmax_t) TYPE_MAXIMUM (minor_t)); } mode_t mode_from_oct (const char *p, size_t s) { - return from_oct (p, s, "mode_t", MODE_MAX); + return from_oct (p, s, "mode_t", (uintmax_t) TYPE_MAXIMUM (mode_t)); } off_t off_from_oct (const char *p, size_t s) { - return from_oct (p, s, "off_t", OFF_MAX); + return from_oct (p, s, "off_t", (uintmax_t) TYPE_MAXIMUM (off_t)); } size_t size_from_oct (const char *p, size_t s) { - return from_oct (p, s, "size_t", SIZE_MAX); + return from_oct (p, s, "size_t", (uintmax_t) TYPE_MAXIMUM (size_t)); } time_t time_from_oct (const char *p, size_t s) { - return from_oct (p, s, "time_t", TIME_MAX); + return from_oct (p, s, "time_t", (uintmax_t) TYPE_MAXIMUM (time_t)); } uid_t uid_from_oct (const char *p, size_t s) { - return from_oct (p, s, "uid_t", UID_MAX); + return from_oct (p, s, "uid_t", (uintmax_t) TYPE_MAXIMUM (uid_t)); } uintmax_t uintmax_from_oct (const char *p, size_t s) { - return from_oct (p, s, "uintmax_t", UINTMAX_MAX); + return from_oct (p, s, "uintmax_t", TYPE_MAXIMUM (uintmax_t)); }