Deleted Added
full compact
archive_read_support_format_tar.c (305188) archive_read_support_format_tar.c (306321)
1/*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * Copyright (c) 2011-2012 Michihiro NAKAJIMA
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "archive_platform.h"
1/*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * Copyright (c) 2011-2012 Michihiro NAKAJIMA
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "archive_platform.h"
28__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c 305188 2016-09-01 07:53:59Z mm $");
28__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_read_support_format_tar.c 306321 2016-09-25 22:02:27Z mm $");
29
30#ifdef HAVE_ERRNO_H
31#include <errno.h>
32#endif
33#include <stddef.h>
34#ifdef HAVE_STDLIB_H
35#include <stdlib.h>
36#endif

--- 94 unchanged lines hidden (view full) ---

131 struct archive_string line;
132 int pax_hdrcharset_binary;
133 int header_recursion_depth;
134 int64_t entry_bytes_remaining;
135 int64_t entry_offset;
136 int64_t entry_padding;
137 int64_t entry_bytes_unconsumed;
138 int64_t realsize;
29
30#ifdef HAVE_ERRNO_H
31#include <errno.h>
32#endif
33#include <stddef.h>
34#ifdef HAVE_STDLIB_H
35#include <stdlib.h>
36#endif

--- 94 unchanged lines hidden (view full) ---

131 struct archive_string line;
132 int pax_hdrcharset_binary;
133 int header_recursion_depth;
134 int64_t entry_bytes_remaining;
135 int64_t entry_offset;
136 int64_t entry_padding;
137 int64_t entry_bytes_unconsumed;
138 int64_t realsize;
139 int sparse_allowed;
139 struct sparse_block *sparse_list;
140 struct sparse_block *sparse_last;
141 int64_t sparse_offset;
142 int64_t sparse_numbytes;
143 int sparse_gnu_major;
144 int sparse_gnu_minor;
145 char sparse_gnu_pending;
146

--- 1119 unchanged lines hidden (view full) ---

1266 archive_entry_set_filetype(entry, AE_IFREG);
1267 break;
1268 case 'S': /* GNU sparse files */
1269 /*
1270 * Sparse files are really just regular files with
1271 * sparse information in the extended area.
1272 */
1273 /* FALLTHROUGH */
140 struct sparse_block *sparse_list;
141 struct sparse_block *sparse_last;
142 int64_t sparse_offset;
143 int64_t sparse_numbytes;
144 int sparse_gnu_major;
145 int sparse_gnu_minor;
146 char sparse_gnu_pending;
147

--- 1119 unchanged lines hidden (view full) ---

1267 archive_entry_set_filetype(entry, AE_IFREG);
1268 break;
1269 case 'S': /* GNU sparse files */
1270 /*
1271 * Sparse files are really just regular files with
1272 * sparse information in the extended area.
1273 */
1274 /* FALLTHROUGH */
1275 case '0':
1276 /*
1277 * Enable sparse file "read" support only for regular
1278 * files and explicit GNU sparse files. However, we
1279 * don't allow non-standard file types to be sparse.
1280 */
1281 tar->sparse_allowed = 1;
1282 /* FALLTHROUGH */
1274 default: /* Regular file and non-standard types */
1275 /*
1276 * Per POSIX: non-recognized types should always be
1277 * treated as regular files.
1278 */
1279 archive_entry_set_filetype(entry, AE_IFREG);
1280 break;
1281 }

--- 443 unchanged lines hidden (view full) ---

1725
1726#ifndef __FreeBSD__
1727 if (value == NULL)
1728 value = ""; /* Disable compiler warning; do not pass
1729 * NULL pointer to strlen(). */
1730#endif
1731 switch (key[0]) {
1732 case 'G':
1283 default: /* Regular file and non-standard types */
1284 /*
1285 * Per POSIX: non-recognized types should always be
1286 * treated as regular files.
1287 */
1288 archive_entry_set_filetype(entry, AE_IFREG);
1289 break;
1290 }

--- 443 unchanged lines hidden (view full) ---

1734
1735#ifndef __FreeBSD__
1736 if (value == NULL)
1737 value = ""; /* Disable compiler warning; do not pass
1738 * NULL pointer to strlen(). */
1739#endif
1740 switch (key[0]) {
1741 case 'G':
1742 /* Reject GNU.sparse.* headers on non-regular files. */
1743 if (strncmp(key, "GNU.sparse", 10) == 0 &&
1744 !tar->sparse_allowed) {
1745 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1746 "Non-regular file cannot be sparse");
1747 return (ARCHIVE_FATAL);
1748 }
1749
1733 /* GNU "0.0" sparse pax format. */
1734 if (strcmp(key, "GNU.sparse.numblocks") == 0) {
1735 tar->sparse_offset = -1;
1736 tar->sparse_numbytes = -1;
1737 tar->sparse_gnu_major = 0;
1738 tar->sparse_gnu_minor = 0;
1739 }
1740 if (strcmp(key, "GNU.sparse.offset") == 0) {

--- 1035 unchanged lines hidden ---
1750 /* GNU "0.0" sparse pax format. */
1751 if (strcmp(key, "GNU.sparse.numblocks") == 0) {
1752 tar->sparse_offset = -1;
1753 tar->sparse_numbytes = -1;
1754 tar->sparse_gnu_major = 0;
1755 tar->sparse_gnu_minor = 0;
1756 }
1757 if (strcmp(key, "GNU.sparse.offset") == 0) {

--- 1035 unchanged lines hidden ---