Deleted Added
full compact
archive_read_support_format_xar.c (324417) archive_read_support_format_xar.c (342360)
1/*-
2 * Copyright (c) 2009 Michihiro NAKAJIMA
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

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

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

18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25#include "archive_platform.h"
26__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_read_support_format_xar.c 324417 2017-10-08 20:54:53Z mm $");
26__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_read_support_format_xar.c 342360 2018-12-21 23:33:05Z mm $");
27
28#ifdef HAVE_ERRNO_H
29#include <errno.h>
30#endif
31#ifdef HAVE_STDLIB_H
32#include <stdlib.h>
33#endif
34#if HAVE_LIBXML_XMLREADER_H

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

162#define HAS_TYPE 0x00080
163#define HAS_DEV 0x00100
164#define HAS_DEVMAJOR 0x00200
165#define HAS_DEVMINOR 0x00400
166#define HAS_INO 0x00800
167#define HAS_FFLAGS 0x01000
168#define HAS_XATTR 0x02000
169#define HAS_ACL 0x04000
27
28#ifdef HAVE_ERRNO_H
29#include <errno.h>
30#endif
31#ifdef HAVE_STDLIB_H
32#include <stdlib.h>
33#endif
34#if HAVE_LIBXML_XMLREADER_H

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

162#define HAS_TYPE 0x00080
163#define HAS_DEV 0x00100
164#define HAS_DEVMAJOR 0x00200
165#define HAS_DEVMINOR 0x00400
166#define HAS_INO 0x00800
167#define HAS_FFLAGS 0x01000
168#define HAS_XATTR 0x02000
169#define HAS_ACL 0x04000
170#define HAS_CTIME 0x08000
171#define HAS_MTIME 0x10000
172#define HAS_ATIME 0x20000
170
171 uint64_t id;
172 uint64_t length;
173 uint64_t offset;
174 uint64_t size;
175 enum enctype encoding;
176 struct chksumval a_sum;
177 struct chksumval e_sum;

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

690 if (file->has != (HAS_PATHNAME | HAS_TYPE))
691 break;
692 /*
693 * If a file type is a directory and it does not have
694 * any metadata, do not export.
695 */
696 file_free(file);
697 }
173
174 uint64_t id;
175 uint64_t length;
176 uint64_t offset;
177 uint64_t size;
178 enum enctype encoding;
179 struct chksumval a_sum;
180 struct chksumval e_sum;

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

693 if (file->has != (HAS_PATHNAME | HAS_TYPE))
694 break;
695 /*
696 * If a file type is a directory and it does not have
697 * any metadata, do not export.
698 */
699 file_free(file);
700 }
698 archive_entry_set_atime(entry, file->atime, 0);
699 archive_entry_set_ctime(entry, file->ctime, 0);
700 archive_entry_set_mtime(entry, file->mtime, 0);
701 if (file->has & HAS_ATIME) {
702 archive_entry_set_atime(entry, file->atime, 0);
703 }
704 if (file->has & HAS_CTIME) {
705 archive_entry_set_ctime(entry, file->ctime, 0);
706 }
707 if (file->has & HAS_MTIME) {
708 archive_entry_set_mtime(entry, file->mtime, 0);
709 }
701 archive_entry_set_gid(entry, file->gid);
702 if (file->gname.length > 0 &&
703 archive_entry_copy_gname_l(entry, file->gname.s,
704 archive_strlen(&(file->gname)), xar->sconv) != 0) {
705 if (errno == ENOMEM) {
706 archive_set_error(&a->archive, ENOMEM,
707 "Can't allocate memory for Gname");
708 return (ARCHIVE_FATAL);

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

962
963 step = offset - (xar->offset - xar->h_base);
964 if (step > 0) {
965 step = __archive_read_consume(a, step);
966 if (step < 0)
967 return ((int)step);
968 xar->offset += step;
969 } else {
710 archive_entry_set_gid(entry, file->gid);
711 if (file->gname.length > 0 &&
712 archive_entry_copy_gname_l(entry, file->gname.s,
713 archive_strlen(&(file->gname)), xar->sconv) != 0) {
714 if (errno == ENOMEM) {
715 archive_set_error(&a->archive, ENOMEM,
716 "Can't allocate memory for Gname");
717 return (ARCHIVE_FATAL);

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

971
972 step = offset - (xar->offset - xar->h_base);
973 if (step > 0) {
974 step = __archive_read_consume(a, step);
975 if (step < 0)
976 return ((int)step);
977 xar->offset += step;
978 } else {
970 int64_t pos = __archive_read_seek(a, offset, SEEK_SET);
979 int64_t pos = __archive_read_seek(a, xar->h_base + offset, SEEK_SET);
971 if (pos == ARCHIVE_FAILED) {
972 archive_set_error(&(a->archive),
973 ARCHIVE_ERRNO_MISC,
974 "Cannot seek.");
975 return (ARCHIVE_FAILED);
976 }
977 xar->offset = pos;
978 }

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

1762
1763 file = calloc(1, sizeof(*file));
1764 if (file == NULL) {
1765 archive_set_error(&a->archive, ENOMEM, "Out of memory");
1766 return (ARCHIVE_FATAL);
1767 }
1768 file->parent = xar->file;
1769 file->mode = 0777 | AE_IFREG;
980 if (pos == ARCHIVE_FAILED) {
981 archive_set_error(&(a->archive),
982 ARCHIVE_ERRNO_MISC,
983 "Cannot seek.");
984 return (ARCHIVE_FAILED);
985 }
986 xar->offset = pos;
987 }

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

1771
1772 file = calloc(1, sizeof(*file));
1773 if (file == NULL) {
1774 archive_set_error(&a->archive, ENOMEM, "Out of memory");
1775 return (ARCHIVE_FATAL);
1776 }
1777 file->parent = xar->file;
1778 file->mode = 0777 | AE_IFREG;
1770 file->atime = time(NULL);
1771 file->mtime = time(NULL);
1779 file->atime = 0;
1780 file->mtime = 0;
1772 xar->file = file;
1773 xar->xattr = NULL;
1774 for (attr = list->first; attr != NULL; attr = attr->next) {
1775 if (strcmp(attr->name, "id") == 0)
1776 file->id = atol10(attr->value, strlen(attr->value));
1777 }
1778 file->nlink = 1;
1779 if (heap_add_entry(a, &(xar->file_queue), file) != ARCHIVE_OK)

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

2746 xar->file->has |= HAS_UID;
2747 archive_strncpy(&(xar->file->uname), s, len);
2748 break;
2749 case FILE_UID:
2750 xar->file->has |= HAS_UID;
2751 xar->file->uid = atol10(s, len);
2752 break;
2753 case FILE_CTIME:
1781 xar->file = file;
1782 xar->xattr = NULL;
1783 for (attr = list->first; attr != NULL; attr = attr->next) {
1784 if (strcmp(attr->name, "id") == 0)
1785 file->id = atol10(attr->value, strlen(attr->value));
1786 }
1787 file->nlink = 1;
1788 if (heap_add_entry(a, &(xar->file_queue), file) != ARCHIVE_OK)

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

2755 xar->file->has |= HAS_UID;
2756 archive_strncpy(&(xar->file->uname), s, len);
2757 break;
2758 case FILE_UID:
2759 xar->file->has |= HAS_UID;
2760 xar->file->uid = atol10(s, len);
2761 break;
2762 case FILE_CTIME:
2754 xar->file->has |= HAS_TIME;
2763 xar->file->has |= HAS_TIME | HAS_CTIME;
2755 xar->file->ctime = parse_time(s, len);
2756 break;
2757 case FILE_MTIME:
2764 xar->file->ctime = parse_time(s, len);
2765 break;
2766 case FILE_MTIME:
2758 xar->file->has |= HAS_TIME;
2767 xar->file->has |= HAS_TIME | HAS_MTIME;
2759 xar->file->mtime = parse_time(s, len);
2760 break;
2761 case FILE_ATIME:
2768 xar->file->mtime = parse_time(s, len);
2769 break;
2770 case FILE_ATIME:
2762 xar->file->has |= HAS_TIME;
2771 xar->file->has |= HAS_TIME | HAS_ATIME;
2763 xar->file->atime = parse_time(s, len);
2764 break;
2765 case FILE_DATA_LENGTH:
2766 xar->file->has |= HAS_DATA;
2767 xar->file->length = atol10(s, len);
2768 break;
2769 case FILE_DATA_OFFSET:
2770 xar->file->has |= HAS_DATA;

--- 531 unchanged lines hidden ---
2772 xar->file->atime = parse_time(s, len);
2773 break;
2774 case FILE_DATA_LENGTH:
2775 xar->file->has |= HAS_DATA;
2776 xar->file->length = atol10(s, len);
2777 break;
2778 case FILE_DATA_OFFSET:
2779 xar->file->has |= HAS_DATA;

--- 531 unchanged lines hidden ---