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

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

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

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

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include "archive_platform.h"
29__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c 337351 2018-08-05 14:35:30Z mm $");
29__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c 348607 2019-06-04 10:35:54Z mm $");
30
31#ifdef HAVE_SYS_STAT_H
32#include <sys/stat.h>
33#endif
34#ifdef HAVE_ERRNO_H
35#include <errno.h>
36#endif
37#ifdef HAVE_FCNTL_H
38#include <fcntl.h>
39#endif
40#include <stddef.h>
41/* #include <stdint.h> */ /* See archive_platform.h */
42#ifdef HAVE_STDLIB_H
43#include <stdlib.h>
44#endif
45#ifdef HAVE_STRING_H
46#include <string.h>
47#endif
30
31#ifdef HAVE_SYS_STAT_H
32#include <sys/stat.h>
33#endif
34#ifdef HAVE_ERRNO_H
35#include <errno.h>
36#endif
37#ifdef HAVE_FCNTL_H
38#include <fcntl.h>
39#endif
40#include <stddef.h>
41/* #include <stdint.h> */ /* See archive_platform.h */
42#ifdef HAVE_STDLIB_H
43#include <stdlib.h>
44#endif
45#ifdef HAVE_STRING_H
46#include <string.h>
47#endif
48#ifdef HAVE_CTYPE_H
49#include <ctype.h>
50#endif
48
49#include "archive.h"
50#include "archive_entry.h"
51#include "archive_private.h"
52#include "archive_rb.h"
53#include "archive_read_private.h"
54#include "archive_string.h"
55#include "archive_pack_dev.h"

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

1006 }
1007}
1008
1009static int
1010read_mtree(struct archive_read *a, struct mtree *mtree)
1011{
1012 ssize_t len;
1013 uintmax_t counter;
51
52#include "archive.h"
53#include "archive_entry.h"
54#include "archive_private.h"
55#include "archive_rb.h"
56#include "archive_read_private.h"
57#include "archive_string.h"
58#include "archive_pack_dev.h"

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

1009 }
1010}
1011
1012static int
1013read_mtree(struct archive_read *a, struct mtree *mtree)
1014{
1015 ssize_t len;
1016 uintmax_t counter;
1014 char *p;
1017 char *p, *s;
1015 struct mtree_option *global;
1016 struct mtree_entry *last_entry;
1017 int r, is_form_d;
1018
1019 mtree->archive_format = ARCHIVE_FORMAT_MTREE;
1020 mtree->archive_format_name = "mtree";
1021
1022 global = NULL;
1023 last_entry = NULL;
1024
1025 (void)detect_form(a, &is_form_d);
1026
1027 for (counter = 1; ; ++counter) {
1018 struct mtree_option *global;
1019 struct mtree_entry *last_entry;
1020 int r, is_form_d;
1021
1022 mtree->archive_format = ARCHIVE_FORMAT_MTREE;
1023 mtree->archive_format_name = "mtree";
1024
1025 global = NULL;
1026 last_entry = NULL;
1027
1028 (void)detect_form(a, &is_form_d);
1029
1030 for (counter = 1; ; ++counter) {
1031 r = ARCHIVE_OK;
1028 len = readline(a, mtree, &p, 65536);
1029 if (len == 0) {
1030 mtree->this_entry = mtree->entries;
1031 free_options(global);
1032 return (ARCHIVE_OK);
1033 }
1034 if (len < 0) {
1035 free_options(global);

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

1040 ++p;
1041 --len;
1042 }
1043 /* Skip content lines and blank lines. */
1044 if (*p == '#')
1045 continue;
1046 if (*p == '\r' || *p == '\n' || *p == '\0')
1047 continue;
1032 len = readline(a, mtree, &p, 65536);
1033 if (len == 0) {
1034 mtree->this_entry = mtree->entries;
1035 free_options(global);
1036 return (ARCHIVE_OK);
1037 }
1038 if (len < 0) {
1039 free_options(global);

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

1044 ++p;
1045 --len;
1046 }
1047 /* Skip content lines and blank lines. */
1048 if (*p == '#')
1049 continue;
1050 if (*p == '\r' || *p == '\n' || *p == '\0')
1051 continue;
1052 /* Non-printable characters are not allowed */
1053 for (s = p;s < p + len - 1; s++) {
1054 if (!isprint(*s)) {
1055 r = ARCHIVE_FATAL;
1056 break;
1057 }
1058 }
1059 if (r != ARCHIVE_OK)
1060 break;
1048 if (*p != '/') {
1049 r = process_add_entry(a, mtree, &global, p, len,
1050 &last_entry, is_form_d);
1051 } else if (len > 4 && strncmp(p, "/set", 4) == 0) {
1052 if (p[4] != ' ' && p[4] != '\t')
1053 break;
1054 r = process_global_set(a, &global, p);
1055 } else if (len > 6 && strncmp(p, "/unset", 6) == 0) {

--- 956 unchanged lines hidden ---
1061 if (*p != '/') {
1062 r = process_add_entry(a, mtree, &global, p, len,
1063 &last_entry, is_form_d);
1064 } else if (len > 4 && strncmp(p, "/set", 4) == 0) {
1065 if (p[4] != ' ' && p[4] != '\t')
1066 break;
1067 r = process_global_set(a, &global, p);
1068 } else if (len > 6 && strncmp(p, "/unset", 6) == 0) {

--- 956 unchanged lines hidden ---