1 /*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * Copyright (c) 2009 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:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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 #include "test.h"
27
28 #define UID 1001
29 #define UNAME "cue"
30 #define GID 1001
31 #define GNAME "cue"
32
33 /* Verify that a file records with hardlink.
34 #How to make
35 echo "hellohellohello" > f1
36 chown $UNAME:$GNAME f1
37 chmod 0644 f1
38 ln f1 hardlink
39 chown $UNAME:$GNAME hardlink
40 chmod 0644 hardlink
41 env TZ=utc touch -afm -t 197001020000.01 f1 hardlink
42 xar -cf archive1.xar f1 hardlink
43 od -t x1 archive1.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive1.xar.txt
44 */
45 static unsigned char archive1[] = {
46 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xc6,
47 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x70,0x00,0x00,0x00,0x01,0x78,0xda,0xc4,0x54,
48 0xc9,0x6e,0xdb,0x30,0x14,0xbc,0xe7,0x2b,0x08,0xdd,0x55,0xae,0xb6,0x45,0x83,0x56,
49 0xd0,0x4b,0xd1,0x7b,0xd3,0x4b,0x6f,0x34,0x17,0x89,0x88,0x36,0x48,0x54,0xe0,0xe4,
50 0xeb,0x4b,0x52,0x52,0x0c,0xa7,0x71,0x6f,0x45,0x01,0x01,0x1a,0x0e,0x87,0xa3,0xa7,
51 0xf7,0x06,0x14,0x8f,0x97,0xb6,0x01,0x2f,0x66,0x9c,0x5c,0xdf,0x9d,0x32,0xfc,0x05,
52 0x65,0xc0,0x74,0xaa,0xd7,0xae,0xab,0x4e,0xd9,0xcf,0xa7,0x6f,0x79,0x91,0x3d,0x96,
53 0x0f,0xe2,0x22,0xc7,0xf2,0x01,0x08,0xdf,0xab,0xf0,0x02,0x42,0x8d,0x46,0xfa,0x70,
54 0x22,0xf7,0xae,0x35,0x25,0x41,0x88,0xe7,0x98,0xe4,0x88,0x3c,0x61,0x7a,0xa4,0xe8,
55 0x48,0xb9,0x80,0xb7,0x92,0x74,0xa8,0x36,0xea,0x79,0x9a,0x5b,0x30,0xf9,0xd7,0xc6,
56 0x9c,0xb2,0xa9,0x96,0x38,0x8b,0x3b,0x40,0xf4,0xd6,0x4e,0xc6,0x97,0x48,0xc0,0x15,
57 0x25,0x76,0x72,0x6f,0xd1,0x5c,0xc0,0x04,0xa2,0x05,0xdc,0x3c,0xd2,0xca,0xba,0xc6,
58 0x00,0xa7,0x4f,0x19,0x59,0x6d,0xd4,0x9d,0x72,0xd8,0xaf,0x70,0x72,0xab,0x03,0x88,
59 0x36,0x41,0xcc,0x0f,0x28,0x47,0x38,0xca,0x10,0x3a,0xc6,0x07,0x07,0x59,0x7b,0x95,
60 0xc9,0x7b,0x3f,0x17,0x64,0xf2,0x2a,0xab,0xc6,0x7e,0x1e,0x4a,0x35,0x1b,0x01,0x17,
61 0xb8,0xb0,0x4e,0x97,0x18,0x21,0x1c,0xc8,0x80,0x12,0x35,0x4f,0x66,0x5c,0x74,0x09,
62 0x2d,0xdc,0xbb,0x6c,0xde,0x64,0x6d,0xaf,0x4d,0x89,0xf6,0x8c,0x85,0x62,0x22,0x4c,
63 0xa4,0x7f,0x1d,0x0c,0x68,0x5c,0xf7,0x1c,0x66,0x94,0x95,0xb5,0x1c,0x75,0x5c,0x08,
64 0x18,0xf9,0x45,0xd1,0xc9,0x50,0xd0,0x75,0x23,0x2d,0x53,0xcb,0x62,0x97,0x6e,0xdb,
65 0xb5,0x75,0x5d,0x4b,0x2f,0x13,0x02,0xa2,0x31,0x5d,0xe5,0xeb,0x92,0x50,0x01,0x57,
66 0xb8,0xf0,0xeb,0x38,0xc8,0xed,0x64,0xd6,0xd1,0xe0,0xfd,0x75,0x34,0x81,0xdb,0x72,
67 0xb3,0xcd,0x57,0x0e,0x43,0xe3,0x54,0x0a,0x01,0xbc,0xe4,0xd5,0x9b,0x1b,0x32,0xb8,
68 0x4a,0xe5,0xa8,0x6a,0xf7,0x62,0x74,0xfe,0x31,0x13,0x3f,0xbe,0x7f,0x0d,0xd5,0xd9,
69 0x82,0x52,0x4d,0xac,0x56,0x98,0x53,0xc6,0xa9,0x3c,0xb3,0x82,0x4b,0x2d,0x09,0xb5,
70 0x85,0x3d,0x70,0x6c,0xf7,0xc4,0x2a,0xba,0xe7,0x45,0x98,0xc3,0x47,0xa3,0xad,0x96,
71 0x8b,0x1f,0xa5,0xf2,0x77,0xbf,0xb0,0xd3,0x07,0x76,0x56,0x67,0x75,0xe0,0x9a,0x5a,
72 0x7e,0xb6,0x4c,0xda,0xe0,0xcd,0x8a,0xa2,0x40,0x86,0xed,0xc8,0x7e,0xc7,0xac,0x41,
73 0x8a,0x87,0x1c,0xff,0xe9,0xb4,0x34,0x0f,0xbe,0x77,0xef,0x9f,0xc4,0xee,0x73,0xd9,
74 0x7f,0x8c,0x5d,0x3f,0xba,0xca,0x75,0xb2,0xf9,0x4b,0xfa,0x2c,0xfe,0x24,0x77,0x41,
75 0x15,0x2f,0x0d,0x01,0xd3,0x15,0xf2,0x1b,0x00,0x00,0xff,0xff,0x03,0x00,0x88,0x32,
76 0x49,0x7b,0x67,0xbf,0xc6,0x01,0x29,0xf2,0x1c,0x40,0x05,0x3c,0x49,0x25,0x9f,0xab,
77 0x7c,0x8e,0xc5,0xa5,0x79,0xe0,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,0x80,0x13,
78 0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47
79 };
80
verify0(struct archive * a,struct archive_entry * ae)81 static void verify0(struct archive *a, struct archive_entry *ae)
82 {
83 const void *p;
84 size_t size;
85 int64_t offset;
86
87 assert(archive_entry_filetype(ae) == AE_IFREG);
88 assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
89 assertEqualInt(archive_entry_uid(ae), UID);
90 assertEqualInt(archive_entry_gid(ae), GID);
91 assertEqualString(archive_entry_uname(ae), UNAME);
92 assertEqualString(archive_entry_gname(ae), GNAME);
93 assertEqualString(archive_entry_pathname(ae), "f1");
94 assert(archive_entry_hardlink(ae) == NULL);
95 assert(archive_entry_symlink(ae) == NULL);
96 assertEqualInt(archive_entry_mtime(ae), 86401);
97 assertEqualInt(archive_entry_size(ae), 16);
98 assertEqualInt(archive_read_data_block(a, &p, &size, &offset), 0);
99 assertEqualInt((int)size, 16);
100 assertEqualInt((int)offset, 0);
101 assertEqualMem(p, "hellohellohello\n", 16);
102 }
103
verify1(struct archive * a,struct archive_entry * ae)104 static void verify1(struct archive *a, struct archive_entry *ae)
105 {
106 (void)a; /* UNUSED */
107 /* A hardlink is not a symlink. */
108 assert(archive_entry_filetype(ae) != AE_IFLNK);
109 /* Nor is it a directory. */
110 assert(archive_entry_filetype(ae) != AE_IFDIR);
111 assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
112 assertEqualInt(archive_entry_uid(ae), UID);
113 assertEqualInt(archive_entry_gid(ae), GID);
114 assertEqualString(archive_entry_uname(ae), UNAME);
115 assertEqualString(archive_entry_gname(ae), GNAME);
116 assertEqualString(archive_entry_pathname(ae), "hardlink");
117 assertEqualString(archive_entry_hardlink(ae), "f1");
118 assert(archive_entry_symlink(ae) == NULL);
119 assertEqualInt(archive_entry_mtime(ae), 86401);
120 assertEqualInt(archive_entry_nlink(ae), 2);
121 }
122
123 /* Verify that symlinks are read correctly.
124 #How to make
125 echo "hellohellohello" > f1
126 chown $UNAME:$GNAME f1
127 chmod 0644 f1
128 ln -s f1 symlink
129 chown $UNAME:$GNAME symlink
130 chmod 0644 symlink
131 env TZ=utc touch -afm -t 197001020000.01 f1 symlink
132 xar -cf archive2.xar f1 symlink
133 od -t x1 archive2.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive2.xar.txt
134 */
135 static unsigned char archive2[] = {
136 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe8,
137 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x84,0x00,0x00,0x00,0x01,0x78,0xda,0xb4,0x54,
138 0xcb,0x6e,0xa3,0x30,0x14,0xdd,0xf7,0x2b,0x90,0xf7,0x8c,0x1f,0x40,0x82,0x23,0xe3,
139 0xaa,0x9b,0x6a,0xf6,0xd3,0xd9,0xcc,0xce,0xf1,0x83,0x58,0xe5,0x25,0x70,0xaa,0xa4,
140 0x5f,0x3f,0xb6,0x09,0x4d,0xd3,0x30,0xdd,0x8d,0x84,0xc4,0xf5,0xf1,0xb9,0xc7,0x97,
141 0x7b,0x0f,0x66,0x8f,0xa7,0xb6,0x49,0xde,0xf4,0x38,0xd9,0xbe,0xab,0x00,0xfe,0x81,
142 0x40,0xa2,0x3b,0xd9,0x2b,0xdb,0xd5,0x15,0xf8,0xfd,0xf2,0x9c,0x96,0xe0,0x91,0x3f,
143 0xb0,0x93,0x18,0xf9,0x43,0xc2,0x5c,0x2f,0xfd,0x2b,0x61,0x72,0xd4,0xc2,0xf9,0x8c,
144 0xd4,0xd9,0x56,0x73,0x82,0x10,0x4d,0x31,0x49,0x11,0x79,0xc1,0xd9,0x2e,0x2b,0x76,
145 0xb8,0x60,0xf0,0x96,0x12,0x93,0x0e,0x5a,0xbe,0x4e,0xc7,0x36,0x99,0xdc,0xb9,0xd1,
146 0x15,0x98,0x0e,0x02,0x83,0xb0,0x93,0xb0,0xde,0x98,0x49,0x3b,0x8e,0x18,0xbc,0x44,
147 0x11,0x9d,0xec,0x7b,0x10,0x67,0x30,0x06,0x41,0x02,0x2e,0x1a,0x71,0x65,0x6c,0xa3,
148 0x13,0xab,0x2a,0x40,0x2e,0x32,0xf2,0xae,0x1c,0xb4,0xcb,0xd1,0x0e,0xd1,0x3f,0x3e,
149 0x73,0xa9,0x23,0x61,0xed,0x37,0xb4,0xf6,0x4a,0x13,0xdf,0xd0,0xc4,0x95,0x56,0x8f,
150 0xfd,0x71,0xe0,0xf2,0xa8,0x19,0x9c,0xc3,0x19,0xb5,0x8a,0x63,0x84,0xb0,0x07,0x7d,
151 0x14,0xa1,0xe3,0xa4,0xc7,0x99,0x17,0xa3,0x19,0xfb,0xa0,0x1d,0x17,0x5a,0xdb,0x2b,
152 0xcd,0xd1,0xb6,0xf0,0x3d,0x8c,0x61,0x04,0x1b,0xdb,0xbd,0x26,0xee,0x3c,0xf8,0xb6,
153 0x85,0xaf,0x06,0xdc,0xf8,0x94,0x00,0xce,0xdb,0x61,0x87,0x4f,0xe7,0x36,0x20,0x0c,
154 0xc6,0x55,0xc4,0x3b,0xd1,0x7e,0xc2,0xe3,0x2a,0xb6,0x31,0x68,0xdc,0xb6,0x70,0x99,
155 0x84,0x12,0x4e,0xc4,0xc8,0x9f,0xa9,0xbb,0xda,0x1d,0x38,0xc9,0xfc,0x49,0x73,0x38,
156 0xe3,0x97,0x11,0x91,0xdb,0x69,0x5d,0xc6,0x85,0x37,0xd7,0x71,0x79,0x6c,0xf1,0xd2,
157 0x32,0x73,0x31,0x0c,0x8d,0x95,0xd1,0x18,0xf0,0x94,0xd6,0xef,0x76,0x00,0xf0,0x42,
158 0x15,0xa3,0x3c,0xd8,0x37,0xad,0xd2,0xaf,0x3e,0xf9,0xf5,0xf3,0xc9,0x57,0x67,0xca,
159 0x2c,0x53,0xc4,0x28,0x89,0x69,0x96,0xd3,0x4c,0xec,0xf3,0x92,0x0a,0x25,0x48,0x66,
160 0x4a,0xb3,0xa5,0xd8,0x6c,0x88,0x91,0xd9,0x86,0x96,0x7e,0x36,0x5f,0x85,0x96,0x5a,
161 0x4e,0x6e,0x14,0xd2,0xfd,0xf3,0x84,0x42,0x6d,0xf3,0xbd,0xdc,0xcb,0x2d,0x55,0x99,
162 0xa1,0x7b,0x93,0x0b,0xe3,0xb5,0xf3,0xb2,0x2c,0x91,0xce,0x0b,0xb2,0x29,0x72,0xa3,
163 0x91,0xa4,0x94,0xc1,0x7b,0xa5,0xb9,0x79,0xf0,0xa3,0x7b,0x2b,0x56,0x9c,0xff,0x0c,
164 0xb2,0x66,0x45,0x4c,0xb7,0x28,0x45,0x38,0xd0,0x90,0x37,0x98,0x7f,0xf0,0x9a,0x15,
165 0xd7,0x69,0xff,0xdd,0x8a,0x9b,0x3c,0xff,0x6c,0xc5,0xe0,0xae,0x24,0x18,0xaa,0x02,
166 0xfd,0x68,0x6b,0xdb,0x89,0x06,0xf0,0x83,0x18,0xd5,0xaa,0xf9,0x82,0x4f,0xef,0x7c,
167 0xe7,0x59,0xe1,0x22,0x61,0x30,0x5e,0x2b,0x7f,0x01,0x00,0x00,0xff,0xff,0x03,0x00,
168 0x2b,0xab,0x4f,0xf9,0xbb,0xf7,0x90,0xb5,0x34,0x8f,0x7c,0xae,0x72,0xa0,0x80,0xd2,
169 0x69,0xc7,0xa2,0xe7,0x44,0x53,0xeb,0x75,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,
170 0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47
171 };
172
verify2(struct archive * a,struct archive_entry * ae)173 static void verify2(struct archive *a, struct archive_entry *ae)
174 {
175 (void)a; /* UNUSED */
176 assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
177 assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
178 assertEqualInt(archive_entry_uid(ae), UID);
179 assertEqualInt(archive_entry_gid(ae), GID);
180 assertEqualString(archive_entry_uname(ae), UNAME);
181 assertEqualString(archive_entry_gname(ae), GNAME);
182 assertEqualString(archive_entry_pathname(ae), "symlink");
183 assertEqualString(archive_entry_symlink(ae), "f1");
184 assert(archive_entry_hardlink(ae) == NULL);
185 }
186
187 /* Character device node.
188 #How to make
189 mknod devchar c 0 30
190 chown $UNAME:$GNAME devchar
191 chmod 0644 devchar
192 env TZ=utc touch -afm -t 197001020000.01 devchar
193 xar -cf archive3.xar devchar
194 od -t x1 archive3.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive3.xar.txt
195 */
196 static unsigned char archive3[] = {
197 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x38,
198 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x3b,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x92,
199 0x4d,0x6e,0xc3,0x20,0x10,0x85,0xf7,0x39,0x05,0xf2,0xde,0x05,0x9c,0x9f,0x36,0xd6,
200 0x84,0xec,0x7a,0x82,0x74,0xd3,0x1d,0xc2,0x93,0x98,0xd4,0x36,0x11,0xe0,0x28,0xe9,
201 0xe9,0x0b,0xe3,0xa4,0x69,0xa5,0xaa,0x92,0x25,0x1e,0x8f,0xef,0x8d,0x86,0xc1,0xb0,
202 0xbd,0xf4,0x1d,0x3b,0xa3,0x0f,0xd6,0x0d,0x9b,0x42,0x3e,0x89,0x82,0xe1,0x60,0x5c,
203 0x63,0x87,0xc3,0xa6,0x78,0xdb,0xbd,0x96,0x2f,0xc5,0x56,0xcd,0xe0,0xa2,0xbd,0x9a,
204 0x31,0x88,0xce,0xa4,0x85,0x81,0xf1,0xa8,0x63,0x4a,0x94,0xd1,0xf6,0xa8,0x2a,0x21,
205 0xd6,0xa5,0xac,0x4a,0x51,0xed,0xa4,0xa8,0xab,0x79,0x2d,0x57,0xc0,0x7f,0x23,0x14,
206 0x6a,0xd1,0x7c,0x84,0xb1,0x67,0x21,0x5e,0x3b,0xdc,0x14,0xa1,0xd5,0xb2,0xc8,0x27,
207 0x0c,0xdc,0x7e,0x1f,0x30,0x2a,0x01,0xfc,0xa6,0xc8,0x0d,0xf6,0x33,0x17,0x07,0x4e,
208 0x22,0x97,0xe0,0xf7,0x1a,0xb4,0xdb,0xdb,0x0e,0x99,0x6d,0x52,0xdb,0xb7,0x32,0xe6,
209 0xaf,0x76,0xaa,0x7a,0xb9,0x7c,0x4f,0xc9,0x7b,0x1f,0x0c,0x7a,0x92,0x72,0xfd,0x2c,
210 0x4a,0x21,0x33,0x26,0x44,0x9d,0x3f,0x99,0xb0,0xfe,0x81,0xe9,0x7f,0x30,0xfd,0xc0,
211 0x0e,0xde,0x8d,0x27,0x65,0x46,0x04,0x3e,0xc9,0xc9,0xb5,0x8d,0x92,0x42,0xc8,0x64,
212 0x26,0x45,0xd6,0x18,0xd0,0x4f,0x1c,0xa9,0xc9,0xfb,0xc6,0xc6,0x3b,0xd6,0xbb,0x06,
213 0x95,0x58,0x2d,0x16,0xa9,0x99,0x2c,0xc9,0x6c,0xf0,0x6c,0xcd,0xa4,0x13,0x61,0x07,
214 0xe7,0xd5,0x3c,0x0d,0x66,0x52,0x37,0x57,0x1f,0x93,0xce,0x26,0x09,0x8a,0xf1,0x1f,
215 0x39,0x88,0xd7,0x13,0x2a,0xd3,0x6a,0xaf,0x4d,0x44,0xcf,0xc2,0x09,0x8d,0xd5,0x1d,
216 0x70,0xf2,0x89,0x18,0x74,0xba,0x54,0x8a,0x64,0x08,0x38,0xed,0x68,0xea,0x79,0xd0,
217 0xf9,0xf9,0x39,0xbd,0x3f,0x70,0xfa,0x1b,0xbe,0x00,0x00,0x00,0xff,0xff,0x03,0x00,
218 0xab,0x43,0xa3,0xac,0x76,0x40,0x1e,0x8b,0x95,0x0d,0x28,0x79,0x79,0x43,0x49,0x4e,
219 0x16,0xa1,0x56,0x99,0x1f,0x83,0x77,0x41
220 };
221
verify3(struct archive * a,struct archive_entry * ae)222 static void verify3(struct archive *a, struct archive_entry *ae)
223 {
224 (void)a; /* UNUSED */
225 assertEqualInt(archive_entry_filetype(ae), AE_IFCHR);
226 assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
227 assertEqualInt(archive_entry_uid(ae), UID);
228 assertEqualInt(archive_entry_gid(ae), GID);
229 assertEqualString(archive_entry_uname(ae), UNAME);
230 assertEqualString(archive_entry_gname(ae), GNAME);
231 assertEqualString(archive_entry_pathname(ae), "devchar");
232 assert(archive_entry_symlink(ae) == NULL);
233 assert(archive_entry_hardlink(ae) == NULL);
234 assertEqualInt(archive_entry_mtime(ae), 86401);
235 }
236
237 /* Block device node.
238 #How to make
239 mknod devblock b 0 30
240 chown $UNAME:$GNAME devblock
241 chmod 0644 devblock
242 env TZ=utc touch -afm -t 197001020000.01 devblock
243 xar -cf archive4.xar devblock
244 od -t x1 archive4.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive4.xar.txt
245 */
246 static unsigned char archive4[] = {
247 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x34,
248 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x38,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x92,
249 0xc1,0x6e,0xc2,0x30,0x0c,0x86,0xef,0x3c,0x45,0xd4,0x7b,0x17,0x07,0xd0,0x0a,0x95,
250 0x09,0xb7,0x3d,0x01,0xbb,0xec,0x96,0xa5,0x06,0x32,0xda,0xa6,0x6a,0x5a,0x04,0x7b,
251 0xfa,0x25,0x2e,0x8c,0x4d,0x9a,0x26,0x55,0xea,0x97,0x3f,0x9f,0x2d,0x37,0x29,0x6e,
252 0x2f,0x4d,0x2d,0xce,0xd4,0x07,0xe7,0xdb,0x4d,0xa6,0x9e,0x20,0x13,0xd4,0x5a,0x5f,
253 0xb9,0xf6,0xb0,0xc9,0x5e,0x77,0x2f,0xf9,0x2a,0xdb,0xea,0x19,0x5e,0x4c,0xaf,0x67,
254 0x02,0x07,0x6f,0xe3,0x4b,0xa0,0xed,0xc9,0x0c,0xb1,0x22,0x1f,0x5c,0x43,0x7a,0x0e,
255 0xb0,0xce,0xd5,0x3c,0x87,0xf9,0x4e,0x41,0xb9,0x58,0x95,0xaa,0x40,0xf9,0x5b,0xe1,
256 0xa2,0x23,0xd9,0x53,0x18,0x1b,0x11,0x86,0x6b,0x4d,0x9b,0x2c,0x1c,0x8d,0xca,0xd2,
257 0x8e,0x40,0xbf,0xdf,0x07,0x1a,0x34,0xa0,0xbc,0x11,0xa7,0xc1,0x7d,0xa6,0xe6,0x28,
258 0x19,0x52,0x0b,0x79,0xef,0xc1,0xab,0xbd,0xab,0x49,0xb8,0x2a,0x8e,0x7d,0x6b,0x63,
259 0xff,0x1e,0x07,0x8a,0xb7,0x58,0x79,0x9f,0x43,0x60,0xc3,0xa8,0xd6,0x05,0xe4,0xa0,
260 0x92,0x06,0x50,0xa6,0x47,0x45,0xad,0x79,0x68,0xe6,0x1f,0xcd,0x3c,0xb4,0x43,0xef,
261 0xc7,0x4e,0xdb,0x91,0x50,0x4e,0x38,0xa5,0xae,0xd2,0x0a,0x40,0xc5,0x30,0x12,0x47,
262 0x63,0xa0,0x7e,0xf2,0x98,0xa6,0xec,0x5b,0x1b,0xef,0x5a,0xe3,0x2b,0xd2,0xf0,0xbc,
263 0x5c,0xc6,0x61,0x12,0x72,0x58,0xd1,0xd9,0xd9,0x89,0xa3,0xe1,0x5a,0xdf,0xeb,0x45,
264 0x3c,0x98,0x89,0x6e,0xa9,0xf9,0x88,0x9c,0x42,0x06,0x2e,0x93,0x3f,0xea,0x70,0xb8,
265 0x76,0xa4,0xdf,0x6b,0x6f,0x4f,0x22,0x74,0x64,0x9d,0xa9,0x51,0x72,0xc6,0xbb,0xad,
266 0x89,0x1f,0x14,0x75,0x16,0x50,0xf2,0x92,0x8f,0x3c,0x9d,0x72,0xba,0x7b,0xc9,0x97,
267 0x8f,0x92,0x7f,0x85,0x2f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0xbe,0x66,0xa2,0x82,
268 0x3a,0x54,0xd3,0x61,0xaa,0x8e,0x30,0x4c,0xc8,0x36,0x3b,0x7a,0xa4,0xb9,0xef,0xfc,
269 0x7a,0x5d,0x21,0xde
270 };
271
verify4(struct archive * a,struct archive_entry * ae)272 static void verify4(struct archive *a, struct archive_entry *ae)
273 {
274 (void)a; /* UNUSED */
275 assertEqualInt(archive_entry_filetype(ae), AE_IFBLK);
276 assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
277 assertEqualInt(archive_entry_uid(ae), UID);
278 assertEqualInt(archive_entry_gid(ae), GID);
279 assertEqualString(archive_entry_uname(ae), UNAME);
280 assertEqualString(archive_entry_gname(ae), GNAME);
281 assertEqualString(archive_entry_pathname(ae), "devblock");
282 assert(archive_entry_symlink(ae) == NULL);
283 assert(archive_entry_hardlink(ae) == NULL);
284 assertEqualInt(archive_entry_mtime(ae), 86401);
285 }
286
287 /* Directory.
288 #How to make
289 mkdir dir1
290 chown $UNAME:$GNAME dir1
291 chmod 0755 dir1
292 env TZ=utc touch -afm -t 197001020000.01 dir1
293 xar -cf archive5.xar dir1
294 od -t x1 archive5.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive5.xar.txt
295 */
296 static unsigned char archive5[] = {
297 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x16,
298 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xec,0x00,0x00,0x00,0x01,0x78,0xda,0x74,0x91,
299 0xc1,0x6e,0xc2,0x30,0x0c,0x86,0xef,0x3c,0x45,0xd4,0x7b,0x17,0xa7,0x83,0x31,0xaa,
300 0x34,0xdc,0xf6,0x04,0xec,0xb2,0x5b,0x95,0x1a,0x88,0x68,0x1a,0x94,0xa4,0x13,0xdd,
301 0xd3,0x2f,0x71,0xe9,0xd0,0xa4,0x4d,0xaa,0xd4,0x3f,0xbf,0x3f,0xff,0xb2,0x6c,0xb9,
302 0xbf,0xd9,0x9e,0x7d,0xa2,0x0f,0xc6,0x0d,0x4d,0x21,0x9e,0xa0,0x60,0x38,0x68,0xd7,
303 0x99,0xe1,0xd4,0x14,0xef,0x87,0xb7,0xf2,0xb5,0xd8,0xab,0x95,0xbc,0xb5,0x5e,0xad,
304 0x98,0x8c,0x4e,0xa7,0x1f,0x93,0xda,0x63,0x1b,0x53,0x47,0x19,0x8d,0x45,0x55,0x01,
305 0xec,0x4a,0x51,0x95,0x50,0x1d,0x04,0xd4,0x6b,0x51,0xaf,0x37,0x92,0xff,0x46,0xa8,
306 0xe9,0x8c,0xfa,0x12,0x46,0xcb,0x42,0x9c,0x7a,0x6c,0x8a,0x70,0x6e,0x45,0x91,0x2b,
307 0x4c,0xba,0xe3,0x31,0x60,0x54,0x20,0xf9,0x5d,0x91,0x1b,0xcc,0x57,0x0e,0x97,0x9c,
308 0x44,0x8e,0xe0,0x4b,0x06,0xbd,0x8e,0xa6,0x47,0x66,0xba,0x34,0xf6,0x3d,0x46,0xff,
309 0x3d,0xce,0x33,0x7c,0xa4,0xce,0x65,0x0e,0x26,0x2d,0x49,0xb1,0xdb,0x42,0x09,0x22,
310 0x63,0x00,0x75,0xfe,0x44,0xc2,0xec,0x03,0x6b,0xff,0x49,0x7b,0x49,0x58,0xfb,0xc0,
311 0x4e,0xde,0x8d,0x57,0xa5,0x47,0x94,0x7c,0x96,0xb3,0x6b,0x3a,0x25,0x00,0x44,0x32,
312 0x93,0x22,0x6b,0x0c,0xe8,0x67,0x8e,0xd4,0xec,0xfd,0x60,0xe3,0x82,0x59,0xd7,0xa1,
313 0x82,0xed,0x26,0xed,0x90,0x24,0x99,0x71,0xba,0xa2,0xea,0x8c,0x47,0x1d,0x9d,0x9f,
314 0x24,0xa7,0x37,0x55,0x86,0xd6,0x52,0x25,0x45,0x90,0xa4,0x35,0xe5,0xcd,0xe4,0x7b,
315 0x71,0x3a,0x98,0xe4,0x74,0xbe,0x6f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x23,0x7a,
316 0x8c,0x2f,0x78,0xe9,0x69,0x28,0x93,0x14,0x72,0x68,0x8d,0xeb,0x42,0x7b,0xf6,0x0f,
317 0x70,0x64,0xa3,0xff,0xb9,0x35
318 };
319
verify5(struct archive * a,struct archive_entry * ae)320 static void verify5(struct archive *a, struct archive_entry *ae)
321 {
322 (void)a; /* UNUSED */
323 assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
324 assertEqualInt(archive_entry_mtime(ae), 86401);
325 assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
326 assertEqualInt(archive_entry_uid(ae), UID);
327 assertEqualInt(archive_entry_gid(ae), GID);
328 assertEqualString(archive_entry_uname(ae), UNAME);
329 assertEqualString(archive_entry_gname(ae), GNAME);
330 }
331
332 /* fifo
333 #How to make
334 mkfifo -m 0755 fifo
335 chown $UNAME:$GNAME fifo
336 env TZ=utc touch -afm -t 197001020000.01 fifo
337 xar -cf archive6.xar fifo
338 od -t x1 archive6.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive6.xar.txt
339 */
340 static unsigned char archive6[] = {
341 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0e,
342 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe7,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x91,
343 0xc1,0x6e,0xc3,0x20,0x0c,0x86,0xef,0x7d,0x0a,0xc4,0x3d,0xc3,0x64,0xab,0xda,0x46,
344 0x94,0xde,0xf6,0x04,0xdd,0x65,0x37,0x44,0x9c,0x16,0x2d,0x84,0x2a,0x90,0xa9,0xdd,
345 0xd3,0x0f,0x9c,0x66,0xd5,0xa4,0x69,0x12,0x52,0xbe,0xfc,0x7c,0xb6,0x2c,0xac,0x0e,
346 0x57,0xdf,0xb3,0x4f,0x1c,0xa3,0x0b,0xc3,0x9e,0xcb,0x27,0xe0,0x0c,0x07,0x1b,0x5a,
347 0x37,0x9c,0xf6,0xfc,0xed,0xf8,0x5a,0x6d,0xf9,0x41,0xaf,0xd4,0xd5,0x8c,0x7a,0xc5,
348 0x54,0x0a,0x36,0x7f,0x98,0xb2,0x23,0x9a,0x94,0x2b,0xaa,0xe4,0x3c,0xea,0x1a,0x60,
349 0x57,0xc9,0xba,0x82,0xfa,0x28,0x65,0xf3,0x02,0x4d,0xbd,0x55,0xe2,0xb7,0x42,0x45,
350 0x67,0xb4,0x1f,0x71,0xf2,0x2c,0xa6,0x5b,0x8f,0x7b,0x1e,0xcf,0x46,0xf2,0x72,0xc3,
351 0x54,0xe8,0xba,0x88,0x49,0x83,0x12,0x77,0xa2,0x34,0xba,0xaf,0xd2,0x5c,0x09,0x82,
352 0xd2,0x42,0x2c,0x3d,0xe8,0xaf,0x73,0x3d,0x32,0xd7,0xe6,0xb1,0xef,0x6d,0xec,0xdf,
353 0xe3,0xc8,0xe7,0xf7,0x5c,0xb9,0xcc,0xc1,0x94,0x27,0x94,0xbb,0x0d,0x54,0x20,0x8b,
354 0x06,0xd0,0x94,0x23,0xb3,0xe6,0x1f,0x9a,0xf9,0x47,0x33,0x0f,0xed,0x34,0x86,0xe9,
355 0xa2,0xed,0x84,0x4a,0xcc,0x38,0xa7,0xae,0xd5,0x12,0x40,0xe6,0x30,0x13,0x45,0x53,
356 0xc4,0x71,0xf6,0x88,0xe6,0xec,0x47,0x9b,0x16,0xcd,0x87,0x16,0x35,0x6c,0xd6,0xeb,
357 0x3c,0x4c,0x41,0x0a,0xd3,0xed,0x82,0xba,0x73,0x5d,0x50,0x82,0x90,0xc2,0xc1,0xf8,
358 0x25,0x24,0xa4,0x17,0x2a,0x8f,0x52,0x56,0x25,0x68,0x57,0x4a,0xd0,0xe6,0xbe,0x01,
359 0x00,0x00,0xff,0xff,0x03,0x00,0x44,0x19,0x8a,0x2a,0x82,0xbc,0x8c,0xae,0x97,0xa7,
360 0x7d,0x65,0xa5,0x82,0xdb,0xaa,0xc2,0xcb,0xbe,0xf0,0x1f,0xd1,0xf9,0x56
361 };
362
verify6(struct archive * a,struct archive_entry * ae)363 static void verify6(struct archive *a, struct archive_entry *ae)
364 {
365 (void)a; /* UNUSED */
366 assertEqualInt(archive_entry_filetype(ae), AE_IFIFO);
367 assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
368 assertEqualInt(archive_entry_uid(ae), UID);
369 assertEqualInt(archive_entry_gid(ae), GID);
370 assertEqualString(archive_entry_uname(ae), UNAME);
371 assertEqualString(archive_entry_gname(ae), GNAME);
372 assertEqualString(archive_entry_pathname(ae), "fifo");
373 assert(archive_entry_symlink(ae) == NULL);
374 assert(archive_entry_hardlink(ae) == NULL);
375 assertEqualInt(archive_entry_mtime(ae), 86401);
376 }
377
378 /* Verify that a file records with directory name.
379 #How to make
380 mkdir dir1
381 echo "hellohellohello" > dir1/f1
382 chown $UNAME:$GNAME dir1/f1
383 chmod 0644 dir1/f1
384 env TZ=utc touch -afm -t 197001020000.01 dir1/f1
385 xar -cf archive7.xar dir1/f1
386 od -t x1 archive7.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive7.xar.txt
387 */
388
389 static unsigned char archive7[] = {
390 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xbb,
391 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x8a,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x53,
392 0xc9,0x6e,0xdb,0x30,0x14,0xbc,0xe7,0x2b,0x04,0xdd,0x55,0x2e,0xa2,0x16,0x1a,0xb4,
393 0x82,0x5e,0x8a,0xdc,0x93,0x5e,0x7a,0xa3,0xb9,0xd8,0x44,0xb5,0x41,0xa2,0x02,0x3b,
394 0x5f,0x5f,0x92,0xa2,0x1c,0xbb,0x59,0x00,0x01,0x1a,0x3e,0xce,0x1b,0x0d,0x9f,0x86,
395 0xec,0xf1,0xdc,0xb5,0xc9,0xab,0x9a,0x66,0x33,0xf4,0xfb,0x14,0xfd,0x80,0x69,0xa2,
396 0x7a,0x31,0x48,0xd3,0x1f,0xf7,0xe9,0xef,0x97,0x5f,0x59,0x9d,0x3e,0x36,0x0f,0xec,
397 0xcc,0xa7,0xe6,0x21,0x61,0x76,0x10,0xee,0x95,0x30,0x31,0x29,0x6e,0x5d,0x47,0x66,
398 0x4d,0xa7,0x1a,0x0c,0x21,0xcd,0x10,0xce,0x20,0x7e,0x41,0x68,0x57,0xe0,0x5d,0x51,
399 0x31,0x70,0x4f,0x09,0x4d,0x27,0x25,0xfe,0xce,0x4b,0x97,0xcc,0xf6,0xd2,0xaa,0x7d,
400 0x3a,0x9f,0x38,0x4a,0xfd,0x4e,0xc2,0x06,0xad,0x67,0x65,0x1b,0xc8,0x40,0x44,0xa1,
401 0x3a,0x9b,0x37,0x2f,0xce,0x40,0x00,0x5e,0x02,0x6c,0x1a,0x61,0xa5,0x4d,0xab,0x12,
402 0x23,0x9d,0xed,0x28,0x63,0x2f,0xa3,0x6a,0xa4,0x99,0x94,0xb0,0xc3,0x74,0x61,0x20,
403 0xac,0xc3,0x4e,0xcf,0xbb,0xb0,0x83,0x18,0x08,0x30,0x14,0xaf,0xfd,0x78,0xed,0x4f,
404 0x98,0xe4,0x96,0xaf,0x30,0x61,0xad,0xea,0x8f,0xf6,0xd4,0xe0,0x9c,0x81,0x08,0xe3,
405 0x46,0xb4,0x88,0xef,0xdd,0x6e,0x7e,0x51,0xf9,0xee,0xd7,0x17,0xb7,0x69,0x6e,0xa7,
406 0xe6,0xe3,0xd8,0x1a,0x11,0x46,0x03,0xce,0xd9,0xf1,0xcd,0x8c,0x29,0xd8,0xb8,0x7c,
407 0x12,0x27,0xf3,0xaa,0x64,0xf6,0xff,0xa8,0x9e,0x9f,0x7e,0xba,0x33,0xea,0x3a,0xcf,
408 0x25,0xd6,0x52,0x20,0x9a,0x13,0x9a,0xf3,0x03,0xa9,0x29,0x97,0x1c,0xe7,0xba,0xd6,
409 0x15,0x45,0xba,0xc4,0x5a,0xe4,0x25,0xad,0x19,0xf8,0x20,0x74,0x75,0x73,0xb6,0x13,
410 0x17,0xf6,0xcb,0x4f,0x14,0xb2,0x22,0x07,0x71,0x10,0x15,0x95,0xb9,0xa6,0x07,0x4d,
411 0xb8,0x76,0xe2,0xa4,0xae,0x6b,0xa8,0x48,0x81,0xcb,0x82,0x68,0x05,0x05,0xa5,0x0c,
412 0x7c,0x54,0x8a,0x33,0x04,0xef,0x43,0x64,0xe2,0xf3,0x7c,0x90,0xfa,0x8f,0xfb,0x95,
413 0x5b,0x30,0x1c,0xaf,0x0b,0x18,0xd1,0x0a,0x66,0x10,0x79,0x1e,0x84,0x3b,0xff,0x20,
414 0xc7,0xeb,0x6e,0x78,0xfc,0x1b,0x1e,0xbf,0xe1,0x1d,0xa7,0x61,0x19,0x1b,0xb1,0x28,
415 0x06,0x56,0x18,0xcb,0x46,0x36,0x08,0x42,0x17,0x02,0x8f,0xd6,0xda,0x32,0xab,0x69,
416 0x65,0x06,0x14,0x8b,0x57,0xe2,0x72,0x25,0x76,0x83,0x54,0x0d,0x2c,0x09,0x71,0x96,
417 0x3c,0x5c,0xab,0x21,0x62,0x3e,0x48,0x37,0x69,0x8b,0x71,0xd3,0x77,0x61,0x03,0x9e,
418 0xb4,0x86,0x38,0x22,0xd7,0xe1,0xaf,0x13,0x03,0xe1,0x72,0xfd,0x03,0x00,0x00,0xff,
419 0xff,0x03,0x00,0x8d,0xb1,0x06,0x76,0xa6,0x7a,0xc3,0xbb,0x13,0x3d,0x45,0xe2,0x2b,
420 0x3b,0xd0,0x88,0xc7,0x58,0x7b,0xbd,0x30,0x9d,0x01,0x44,0x78,0xda,0xca,0x48,0xcd,
421 0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,
422 0x06,0x47
423 };
424
verify7(struct archive * a,struct archive_entry * ae)425 static void verify7(struct archive *a, struct archive_entry *ae)
426 {
427 (void)a; /* UNUSED */
428 assert(archive_entry_filetype(ae) == AE_IFREG);
429 assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
430 assertEqualInt(archive_entry_uid(ae), UID);
431 assertEqualInt(archive_entry_gid(ae), GID);
432 assertEqualString(archive_entry_uname(ae), UNAME);
433 assertEqualString(archive_entry_gname(ae), GNAME);
434 assertEqualString(archive_entry_pathname(ae), "dir1/f1");
435 assert(archive_entry_hardlink(ae) == NULL);
436 assert(archive_entry_symlink(ae) == NULL);
437 assertEqualInt(archive_entry_mtime(ae), 86401);
438 }
439
440 /* Verify that a file records with bzip2 compression
441 #How to make
442 echo "hellohellohello" > f1
443 chown $UNAME:$GNAME f1
444 chmod 0644 f1
445 env TZ=utc touch -afm -t 197001020000.01 f1
446 xar --compression bzip2 -cf archive8.xar f1
447 od -t x1 archive8.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive8.xar.txt
448 */
449
450 static unsigned char archive8[] = {
451 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xb1,
452 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x42,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x53,
453 0xcb,0x6e,0xdc,0x20,0x14,0xdd,0xe7,0x2b,0x90,0xf7,0x0e,0x60,0xe3,0x07,0x23,0x86,
454 0xa8,0x9b,0xa8,0xfb,0x4e,0x37,0xdd,0x61,0x1e,0x63,0x14,0xbf,0x64,0xe3,0x68,0x92,
455 0xaf,0x2f,0x60,0x3b,0xa3,0x34,0x6d,0x25,0x4b,0x3e,0x1c,0x0e,0xe7,0x5e,0xee,0xe5,
456 0xb2,0xa7,0x5b,0xdf,0x81,0x57,0x3d,0x2f,0x76,0x1c,0xce,0x09,0x7e,0x44,0x09,0xd0,
457 0x83,0x1c,0x95,0x1d,0xae,0xe7,0xe4,0xe7,0xe5,0x39,0xad,0x93,0x27,0xfe,0xc0,0x6e,
458 0x62,0xe6,0x0f,0x80,0xb9,0x51,0xfa,0x1f,0x60,0x72,0xd6,0xc2,0xf9,0x13,0xa9,0xb3,
459 0xbd,0xe6,0x19,0x42,0x34,0xc5,0x59,0x8a,0xc8,0x05,0xd1,0x13,0xc6,0x27,0x9c,0x33,
460 0xf8,0x59,0x12,0x0f,0xb5,0x5a,0xbe,0x2c,0x6b,0x0f,0x16,0xf7,0xd6,0xe9,0x73,0xb2,
461 0xb4,0x02,0x27,0x61,0x07,0xb0,0xd1,0x98,0x45,0x3b,0x8e,0x18,0xdc,0x51,0x64,0x17,
462 0xfb,0x1e,0xcc,0x19,0x8c,0x20,0x58,0xc0,0xc3,0x23,0xae,0x8c,0xed,0x34,0xb0,0xca,
463 0xa7,0xbd,0xdb,0x28,0xe1,0x44,0x44,0x80,0x75,0x7a,0xb8,0xba,0x96,0x13,0xc2,0xe0,
464 0x0e,0x37,0x7e,0xf7,0xcf,0x3e,0x87,0xda,0x63,0xe1,0xf2,0x1e,0xcb,0x73,0x47,0x21,
465 0x8e,0x84,0xc5,0x34,0x75,0x56,0xc6,0x5b,0xc1,0x5b,0xda,0xbc,0xdb,0x29,0x4b,0xe0,
466 0xae,0x15,0xb3,0x6c,0xed,0xab,0x56,0xe9,0x9f,0xb7,0xfc,0xf1,0xfd,0x9b,0x4f,0xcf,
467 0xe4,0xa4,0x28,0x4a,0x94,0xcb,0x3a,0xcf,0x9b,0x26,0x93,0xaa,0x92,0xba,0x29,0xa8,
468 0x2a,0x89,0x29,0xa8,0x50,0x22,0x97,0x45,0xa1,0x71,0xe5,0xeb,0xf6,0xc5,0xe8,0x48,
469 0xe6,0xe6,0x66,0x21,0xdd,0x3f,0x23,0x14,0xaa,0x22,0x8d,0x6c,0x64,0x45,0x55,0x6e,
470 0x68,0x63,0x88,0x30,0xa6,0x36,0xa4,0xae,0x6b,0xa4,0x49,0x91,0x95,0x05,0x31,0x1a,
471 0x49,0x4a,0x19,0xfc,0xea,0xb4,0x55,0x0f,0x7e,0x94,0x8f,0xc9,0xbf,0xf7,0x15,0xd5,
472 0xbf,0x7c,0x0b,0x8e,0x86,0x02,0xd6,0x47,0x88,0x69,0x85,0x52,0x84,0x53,0x94,0x5d,
473 0x10,0x3a,0x85,0x0f,0x7b,0x59,0x7f,0x97,0x89,0xff,0xc8,0xc4,0x5d,0x76,0x9d,0xc7,
474 0x75,0xe2,0x72,0xd5,0x0c,0x6e,0x70,0x63,0xad,0xe2,0x18,0x21,0xec,0x49,0x8f,0x22,
475 0xb5,0x2e,0x7a,0xde,0x74,0x11,0x6d,0xdc,0x87,0x6c,0x3d,0x64,0xfd,0xa8,0x34,0x47,
476 0x65,0x78,0x02,0x11,0x46,0xd2,0xbd,0x4d,0x1a,0x74,0x76,0x78,0x39,0x27,0xe3,0x6c,
477 0xaf,0x76,0x10,0x5d,0xc2,0x5b,0x31,0xab,0xc0,0x31,0x18,0xb6,0x37,0xe1,0x20,0x7c,
478 0x5e,0xc6,0xfb,0x45,0x10,0x1f,0x5f,0x78,0x6f,0x61,0x0a,0x60,0x1c,0x03,0x06,0xe3,
479 0x50,0xfc,0x06,0x00,0x00,0xff,0xff,0x03,0x00,0x19,0xcf,0xf5,0xc0,0xf9,0x65,0xe8,
480 0x78,0xc3,0xfa,0x5f,0x0a,0xf6,0x09,0x17,0xd8,0xb0,0x54,0xb9,0x02,0x8d,0x91,0x31,
481 0x9c,0x42,0x5a,0x68,0x39,0x31,0x41,0x59,0x26,0x53,0x59,0xc1,0x52,0x36,0xf7,0x00,
482 0x00,0x03,0x41,0x00,0x00,0x10,0x02,0x44,0xa0,0x00,0x21,0xb4,0x01,0x9a,0x0d,0x46,
483 0xa5,0x32,0x38,0xbb,0x92,0x29,0xc2,0x84,0x86,0x0a,0x91,0xb7,0xb8
484 };
485
486 /* Verify that a file records with no compression
487 #How to make
488 echo "hellohellohello" > f1
489 chown $UNAME:$GNAME f1
490 chmod 0644 f1
491 env TZ=utc touch -afm -t 197001020000.01 f1
492 xar --compression none -cf archive9.xar f1
493 od -t x1 archive9.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive9.xar.txt
494 */
495
496 static unsigned char archive9[] = {
497 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x98,
498 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x47,0x00,0x00,0x00,0x01,0x78,0xda,0xa4,0x53,
499 0x4d,0x6f,0xe3,0x20,0x14,0xbc,0xf7,0x57,0x20,0xee,0x5e,0xc0,0x25,0x89,0x1d,0x11,
500 0xaa,0x5e,0xaa,0xbd,0x6f,0xf6,0xb2,0x37,0x02,0x8f,0x18,0xc5,0x1f,0x11,0xc6,0x55,
501 0xba,0xbf,0x7e,0x01,0xdb,0xad,0xba,0x55,0x7b,0xa9,0x64,0xc9,0xe3,0x61,0xde,0x78,
502 0x78,0xf0,0xc4,0xc3,0xad,0x6b,0xd1,0x33,0xf8,0xd1,0x0d,0xfd,0x01,0xb3,0x1f,0x14,
503 0x23,0xe8,0xf5,0x60,0x5c,0x7f,0x3e,0xe0,0xdf,0xc7,0xa7,0xa2,0xc2,0x0f,0xf2,0x4e,
504 0xdc,0x94,0x97,0x77,0x48,0x84,0x41,0xc7,0x17,0x12,0xda,0x83,0x0a,0xb1,0xa2,0x08,
505 0xae,0x03,0x59,0x52,0x5a,0x17,0xac,0x2c,0x28,0x3f,0xd2,0x7a,0xcf,0xaa,0x3d,0xaf,
506 0x05,0x79,0x2f,0xc9,0x45,0x0d,0xe8,0xcb,0x38,0x75,0x68,0x0c,0x2f,0x2d,0x1c,0xf0,
507 0xd8,0x28,0x86,0xd3,0x0a,0x12,0x83,0xb5,0x23,0x04,0x49,0x05,0x59,0x50,0x66,0x47,
508 0xf7,0x37,0x99,0x0b,0x92,0x41,0xb2,0x20,0xab,0x47,0xfe,0xb2,0xae,0x05,0xe4,0x4c,
509 0x8c,0xbd,0xd8,0x18,0x15,0x54,0x46,0x48,0xb4,0xd0,0x9f,0x43,0x23,0xd9,0x56,0x90,
510 0x05,0xce,0xfc,0xba,0xb9,0x35,0x84,0xba,0x5e,0x5b,0xa7,0x73,0x52,0x32,0xe8,0x00,
511 0xa1,0x18,0x43,0x4c,0xde,0x61,0xb2,0x14,0x2c,0x81,0xca,0xf7,0xd9,0x96,0x70,0xc9,
512 0x7e,0x0d,0x17,0x39,0xe5,0x75,0xe3,0x9e,0xc1,0x14,0xff,0x6f,0xf5,0xd7,0xcf,0xc7,
513 0x98,0x71,0x63,0x76,0xfc,0xa4,0x4f,0x7a,0x57,0x9b,0x7b,0x5b,0x9f,0x2c,0x57,0xd6,
514 0x56,0x96,0x57,0x55,0x45,0x81,0x6f,0xca,0xed,0x86,0x5b,0xa0,0xba,0x8e,0xcd,0xfb,
515 0x60,0xb4,0xa6,0xbf,0x05,0xaf,0x62,0xca,0xef,0xff,0xe1,0xa3,0xd3,0xdc,0x42,0xf2,
516 0xda,0x43,0xa1,0x3f,0x39,0xdc,0xed,0x9f,0x78,0x0e,0xeb,0xa9,0x22,0xd1,0x65,0xc8,
517 0xea,0x1d,0x2d,0x28,0x2b,0x68,0x79,0xa4,0x74,0x9f,0x1e,0x16,0x65,0xdd,0x9b,0x4c,
518 0x7d,0x21,0x53,0x6f,0xb2,0xb3,0x1f,0xa6,0xab,0xd4,0x13,0x08,0x32,0xc3,0x99,0x75,
519 0x46,0x32,0x4a,0x59,0x24,0x23,0xca,0xd4,0x34,0x82,0x9f,0x75,0x19,0xcd,0xdc,0xab,
520 0x6c,0x5a,0x65,0xdd,0x60,0x40,0xd2,0x2d,0xe7,0x31,0x4c,0x82,0x99,0x0c,0x2f,0x57,
521 0x40,0xad,0xeb,0x2f,0x07,0x3c,0x78,0x77,0x76,0xbd,0x6a,0xb1,0x6c,0x94,0x37,0x89,
522 0x13,0x24,0x2d,0xcf,0xc2,0x5e,0xc5,0x5c,0x36,0xfa,0x65,0x90,0x6f,0x60,0xba,0x74,
523 0x69,0x14,0x48,0x9e,0x05,0x41,0xf2,0x64,0xfc,0x03,0x00,0x00,0xff,0xff,0x03,0x00,
524 0xee,0x8e,0xf8,0x75,0xa1,0xaf,0x74,0x71,0x3f,0x40,0x08,0xab,0x13,0x7d,0xc0,0x82,
525 0x3a,0x56,0xeb,0x4e,0x35,0xf1,0x35,0xb7,0x68,0x65,0x6c,0x6c,0x6f,0x68,0x65,0x6c,
526 0x6c,0x6f,0x68,0x65,0x6c,0x6c,0x6f,0x0a
527 };
528
529 /* Verify that a file records with md5 hashing algorithm
530 #How to make
531 echo "hellohellohello" > f1
532 chown $UNAME:$GNAME f1
533 chmod 0644 f1
534 env TZ=utc touch -afm -t 197001020000.01 f1
535 xar --toc-cksum md5 -cf archive10.xar f1
536 od -t x1 archive10.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive10.xar.txt
537 */
538
539 static unsigned char archive10[] = {
540 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xaf,
541 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x40,0x00,0x00,0x00,0x02,0x78,0xda,0x7c,0x53,
542 0x4d,0x6f,0xdc,0x20,0x10,0xbd,0xe7,0x57,0x20,0xee,0x0e,0x60,0xb3,0xb6,0x59,0xb1,
543 0x44,0xbd,0x44,0xbd,0x77,0x7b,0xe9,0x8d,0xe5,0xc3,0x8b,0xe2,0x2f,0x61,0x1c,0x6d,
544 0xf2,0xeb,0x8b,0xb1,0x9d,0xb4,0x4d,0x52,0xc9,0x92,0x1f,0x8f,0xc7,0x9b,0x61,0x86,
545 0xe1,0x0f,0xb7,0xae,0x05,0xcf,0xc6,0x4f,0x6e,0xe8,0x4f,0x90,0xdc,0x63,0x08,0x4c,
546 0xaf,0x06,0xed,0xfa,0xe6,0x04,0x7f,0x9e,0x1f,0xb3,0x1a,0x3e,0x88,0x3b,0x7e,0x93,
547 0x5e,0xdc,0x01,0x1e,0x06,0x15,0x7f,0x80,0x2b,0x6f,0x64,0x88,0x27,0xb2,0xe0,0x3a,
548 0x23,0x72,0x8c,0x59,0x46,0xf2,0x0c,0xd3,0x33,0x66,0xc7,0x02,0x1f,0x69,0xcd,0xd1,
549 0xdf,0x92,0x74,0xe8,0x6a,0xd4,0xd3,0x34,0x77,0x60,0x0a,0x2f,0xad,0x39,0xc1,0x4e,
550 0x1f,0xe0,0xb2,0x01,0xf8,0x60,0xed,0x64,0x82,0xc0,0x1c,0x6d,0x28,0xb1,0x93,0x7b,
551 0x35,0x82,0x94,0x1c,0x25,0xb0,0x38,0xa0,0xdd,0x22,0xad,0xac,0x6b,0x0d,0x70,0x3a,
552 0x66,0xbd,0xd9,0x68,0x19,0x64,0x42,0x80,0xb7,0xa6,0x6f,0xc2,0x55,0xe4,0x05,0x47,
553 0x1b,0x5c,0xf9,0xcd,0x7f,0x71,0xfd,0x23,0xd4,0x27,0xb1,0x22,0xb7,0xd7,0x61,0xcf,
554 0x57,0x8e,0x63,0xeb,0x54,0xba,0x14,0xba,0x65,0xcd,0xab,0x1b,0x21,0xda,0xa4,0xd2,
555 0xab,0xab,0x7b,0x36,0x3a,0xfb,0xf7,0x8e,0x3f,0xbe,0x7f,0x8b,0xd9,0xd9,0xba,0x28,
556 0x74,0x6e,0xb5,0x22,0xac,0xa0,0xac,0x90,0x17,0x5a,0x33,0xa9,0x65,0x5e,0xd8,0xda,
557 0x56,0x8c,0xd8,0x32,0xb7,0xaa,0x28,0x59,0xac,0xda,0x07,0xa3,0x3d,0x97,0x5b,0xf0,
558 0x52,0x85,0x2f,0x23,0x1c,0x74,0x45,0x2f,0xea,0xa2,0x2a,0xa6,0x0b,0xcb,0x2e,0x96,
559 0x4a,0x1b,0xbd,0x69,0x5d,0xd7,0xd8,0xd0,0x43,0x5e,0x1e,0xa8,0x35,0x58,0x31,0xc6,
560 0xd1,0x47,0xa7,0xb5,0x78,0xe8,0xad,0x7a,0x5c,0x7d,0xd1,0xd5,0xea,0x57,0xec,0xc0,
561 0xde,0x4e,0xc0,0xbb,0x04,0x09,0xab,0x70,0x86,0x49,0x86,0xf3,0x33,0xc6,0xc7,0xe5,
562 0x23,0x51,0xd6,0xbd,0xcb,0xe4,0x7f,0x64,0xf2,0x5d,0xd6,0xf8,0x61,0x1e,0x85,0x9a,
563 0x0d,0x47,0x2b,0x5c,0x59,0xa7,0x05,0xc1,0x98,0x44,0x32,0xa2,0x44,0xcd,0x93,0xf1,
564 0xab,0x2e,0xa1,0x95,0x7b,0x93,0xcd,0xbb,0xac,0x1b,0xb4,0x11,0xb8,0xa4,0x34,0x26,
565 0xb3,0xc0,0x44,0x86,0x97,0xd1,0x80,0xd6,0xf5,0x4f,0x27,0x38,0x78,0xd7,0xb8,0x5e,
566 0xb6,0x50,0x5c,0xa5,0xd7,0x0b,0xc7,0xd1,0xb2,0xbd,0x0a,0x7b,0x19,0xf3,0xb2,0xd1,
567 0x2f,0x81,0xf4,0xf6,0x96,0xe7,0xb6,0xcc,0x00,0x4a,0x43,0xc0,0x51,0x1a,0x89,0xdf,
568 0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x27,0xf8,0xf5,0x28,0x87,0x01,0xb1,0xb7,0x18,
569 0xe8,0x34,0x20,0x06,0x5c,0x66,0x9a,0x43,0x26,0xe7,0x94,0x78,0xda,0xca,0x48,0xcd,
570 0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,
571 0x06,0x47
572 };
573
574 /* Verify that a file records with no hashing algorithm
575 #How to make
576 echo "hellohellohello" > f1
577 chown $UNAME:$GNAME f1
578 chmod 0644 f1
579 env TZ=utc touch -afm -t 197001020000.01 f1
580 xar --toc-cksum none -cf archive11.xar f1
581 od -t x1 archive11.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive11.xar.txt
582 */
583
584 static unsigned char archive11[] = {
585 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x98,
586 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xef,0x00,0x00,0x00,0x00,0x78,0xda,0x7c,0x52,
587 0xcb,0x6e,0xeb,0x20,0x14,0xdc,0xf7,0x2b,0x10,0x7b,0x17,0xb0,0x89,0x63,0x22,0x42,
588 0x75,0x37,0x55,0xf7,0xcd,0xdd,0x74,0x47,0x78,0x38,0xa8,0x7e,0xc9,0xc6,0x55,0xda,
589 0xaf,0xbf,0x3c,0xe2,0x56,0x55,0xd5,0x2b,0x21,0x79,0x3c,0xcc,0x39,0x67,0x74,0x18,
590 0xfe,0x70,0xed,0x3b,0xf0,0x66,0xe6,0xc5,0x8d,0xc3,0x11,0x92,0x7b,0x0c,0x81,0x19,
591 0xd4,0xa8,0xdd,0xd0,0x1e,0xe1,0xdf,0xd3,0x63,0xd1,0xc0,0x07,0x71,0xc7,0xaf,0x72,
592 0x16,0x77,0x80,0xfb,0x51,0x85,0x0f,0xe0,0x6a,0x36,0xd2,0x87,0x8a,0xc2,0xbb,0xde,
593 0x88,0x12,0x63,0x56,0x90,0xb2,0xc0,0xf4,0x44,0xf0,0x81,0x54,0x07,0x5a,0x73,0xf4,
594 0x5d,0x12,0x8b,0xac,0xeb,0x0c,0x70,0x3a,0x4c,0x81,0xf1,0x1f,0x70,0x2d,0xbd,0x4c,
595 0x08,0xf0,0xce,0x0c,0xad,0xbf,0x88,0xb2,0xe2,0xe8,0x06,0x33,0x3f,0x5a,0xbb,0x18,
596 0x2f,0x30,0x47,0x37,0x94,0xe9,0xc5,0x7d,0x18,0x41,0xc2,0x94,0x04,0x32,0xb7,0xd9,
597 0x06,0x8b,0x7f,0xef,0xcc,0x11,0xca,0x69,0xea,0x9c,0x4a,0x1e,0xd0,0xb5,0x68,0x3f,
598 0xdc,0x04,0xd1,0x4d,0x2a,0x67,0x75,0x71,0x6f,0x46,0x17,0xea,0x62,0xd4,0xeb,0xb2,
599 0xf6,0x5b,0xcd,0xf3,0xd3,0x9f,0x60,0xce,0x36,0x55,0xa5,0x4b,0xab,0x15,0x61,0x15,
600 0x65,0x95,0x3c,0xd3,0x86,0x49,0x2d,0xcb,0xca,0x36,0x76,0xcf,0x88,0xad,0x4b,0xab,
601 0xaa,0x9a,0x35,0x1c,0xfd,0x68,0xb4,0x79,0xb9,0xfa,0x59,0x2a,0xff,0xeb,0x84,0x9d,
602 0xde,0xd3,0xb3,0x3a,0xab,0x3d,0xd3,0x95,0x65,0x67,0x4b,0xa5,0x0d,0xbd,0x69,0xd3,
603 0x34,0xd8,0xd0,0x5d,0x59,0xef,0xa8,0x35,0x58,0x31,0xc6,0xd1,0xcf,0x4e,0x79,0x77,
604 0xe8,0x73,0x79,0x5c,0xfd,0xf2,0x08,0xe4,0x25,0xbc,0xc2,0xb6,0x7d,0xc0,0xfb,0x04,
605 0x09,0xdb,0xe3,0x02,0x93,0x02,0x97,0x27,0x8c,0x0f,0xf1,0x44,0x59,0xff,0x25,0x93,
606 0xff,0x91,0xc9,0x2f,0x59,0x3b,0x8f,0xeb,0x24,0xd4,0x6a,0x38,0xca,0x30,0xb3,0x4e,
607 0x0b,0x82,0x31,0x09,0x64,0x40,0x89,0x5a,0x17,0x33,0x67,0x5d,0x42,0x99,0xfb,0x94,
608 0xad,0x9b,0xac,0x1f,0xb5,0x11,0xb8,0xa6,0x34,0x98,0x89,0x30,0x91,0xfe,0x7d,0x32,
609 0xa0,0x73,0xc3,0xeb,0x11,0x8e,0xb3,0x6b,0xdd,0x20,0x3b,0x28,0x2e,0x72,0xd6,0x91,
610 0xe3,0x28,0x5e,0x67,0xe1,0x20,0x83,0x2f,0x1b,0xfa,0x25,0x10,0xc3,0x86,0x62,0xda,
611 0x62,0x64,0x51,0xca,0x2c,0x47,0x29,0xc1,0xff,0x00,0x00,0x00,0xff,0xff,0x03,0x00,
612 0xf1,0x18,0xdc,0x71,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,
613 0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47
614 };
615
616 /* Verify that a file which is missing timestamp information
617 has the corresponding timestamps unset.
618 #How to make e.g.
619 struct archive *a = archive_write_new();
620 archive_write_set_format_xar(a);
621 archive_write_add_filter_none(a);
622 size_t used, buffsize = 1500;
623 char *buff = malloc(buffsize);
624 archive_write_open_memory(a, buff, buffsize, &used);
625
626 struct archive_entry *ae = archive_entry_new();
627 archive_entry_copy_pathname(ae, "file");
628 archive_entry_set_size(ae, 8);
629 archive_write_header(a, ae);
630 archive_entry_free(ae);
631 archive_write_data(a, "12345678", 9);
632 archive_write_free(a);
633
634 std::cout << std::string(buff, used);
635 free(buff);
636
637 $./a.out > f12.xar
638 Verify toc has no mtime/atime sections
639 $ xar --dump-toc=- -f f12.xar
640 Dump contents
641 $ ./a.out | od -t x1 | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D'
642 */
643
644 static unsigned char archive12[] = {
645 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd1,
646 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x56,0x00,0x00,0x00,0x01,0x78,0x9c,0x55,0x90,
647 0x41,0x8e,0xc2,0x30,0x0c,0x45,0xf7,0x9c,0x22,0xca,0xbe,0x38,0x2d,0x2c,0x10,0x72,
648 0xdb,0xdd,0x9c,0x00,0x0e,0x50,0xb5,0x6e,0x89,0x68,0x12,0xd4,0x84,0x11,0x70,0x7a,
649 0x62,0x17,0x46,0x9a,0x28,0x92,0xbf,0x5f,0xec,0xef,0xc8,0xd8,0x3e,0xdc,0xac,0x7e,
650 0x69,0x89,0x36,0xf8,0x5a,0x97,0x5b,0xa3,0x15,0xf9,0x3e,0x0c,0xd6,0x4f,0xb5,0x3e,
651 0x9f,0x7e,0x8a,0x83,0x6e,0x9b,0x0d,0x3e,0xba,0xa5,0xd9,0x28,0x4c,0xa1,0xcf,0x41,
652 0x61,0xbf,0x50,0x97,0x72,0x47,0x91,0xac,0xa3,0xa6,0x32,0xe5,0xa1,0x28,0x4d,0x61,
653 0xaa,0x53,0x65,0x8e,0xf9,0xee,0x77,0x08,0xff,0x4b,0xa4,0xe9,0x42,0xfd,0x35,0xde,
654 0x9d,0x8a,0xe9,0x39,0x53,0xad,0xe3,0xa5,0x2b,0x35,0xbf,0x28,0x0c,0xe3,0x18,0x29,
655 0x35,0x06,0xe1,0xa3,0x84,0x46,0xfb,0x62,0x73,0x04,0x11,0x6c,0x01,0x5f,0x0f,0xc9,
656 0x46,0x3b,0x93,0xb2,0x43,0xfe,0xf6,0xc7,0xc6,0x77,0x79,0x14,0x53,0x04,0x91,0x02,
657 0xd3,0xf3,0xf6,0x85,0x22,0x05,0x5a,0x1f,0x06,0xe2,0x79,0xab,0x10,0xe6,0x04,0xe5,
658 0x83,0xe0,0xfe,0xe0,0xdd,0x0e,0x5c,0xc6,0x41,0xf2,0x69,0xcd,0xa7,0x35,0x47,0x60,
659 0x63,0xde,0x0c,0xc8,0x6a,0x10,0x64,0x51,0x6f,0x2a,0x6b,0x63,0x9a,0x01,0x79,0x57,
660 0x93,0xd4,0x55,0xd4,0x06,0x1c,0x76,0x99,0x10,0x31,0x87,0x52,0x2b,0x16,0xff,0x5b,
661 0x36,0x78,0x9c,0x55,0x90,0x41,0x8e,0xc2,0x30,0x0c,0x45,0xf7,0x9c,0x22,0xca,0xbe,
662 0x38,0x2d,0x2c,0x10,0x72
663 };
664
verify12(struct archive * a,struct archive_entry * ae)665 static void verify12(struct archive *a, struct archive_entry *ae)
666 {
667 (void)a; /* UNUSED */
668 assertEqualInt(archive_entry_mtime_is_set(ae), 0);
669 assertEqualInt(archive_entry_atime_is_set(ae), 0);
670 assertEqualInt(archive_entry_mtime(ae), 0);
671 assertEqualInt(archive_entry_atime(ae), 0);
672 }
673
674
675 /*
676 #How to make
677 echo "onetwothree" > f1
678 echo "fourfivesize" > f2
679 xar -cf archive13.xar f1 f2
680 od -t x1 archive13.xar | sed -E -e 's/^0[0-9]+//' | sed -E -e 's/^ //' | sed -E -e 's/( )([0-9a-f]{2})/0x\2,/g;$ D'
681 */
682
683 static unsigned char archive13[] = {
684 0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x31,
685 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0xaa,0x00,0x00,0x00,0x01,0x78,0xda,0xcc,0x95,
686 0xcb,0x8e,0x9b,0x30,0x14,0x86,0xf7,0x79,0x0a,0xc4,0x9e,0xe2,0x0b,0xbe,0x10,0x39,
687 0xcc,0xae,0x4f,0x30,0xdd,0x74,0x67,0xec,0x43,0x82,0x86,0x4b,0x04,0x24,0xcd,0xcc,
688 0xd3,0xd7,0x36,0x30,0x69,0x34,0xd3,0x51,0xda,0x4a,0xa3,0x8a,0x05,0xbf,0x8f,0x7f,
689 0x9f,0xe3,0x63,0x3e,0x64,0xf5,0x70,0x69,0x9b,0xe8,0x0c,0xc3,0x58,0xf7,0xdd,0x2e,
690 0xc6,0x5f,0x50,0x1c,0x41,0x67,0x7a,0x5b,0x77,0xfb,0x5d,0xfc,0xed,0xf1,0x6b,0x22,
691 0xe3,0x87,0x62,0xa3,0x2e,0x7a,0x28,0x36,0x91,0x9a,0x7a,0xe3,0x5e,0x91,0x32,0x03,
692 0xe8,0xc9,0xad,0x48,0xa6,0xba,0x85,0x82,0x20,0x2c,0x13,0x44,0x12,0xc2,0x1f,0x71,
693 0xbe,0xc5,0x68,0x4b,0xf3,0xef,0x2a,0xbd,0xf5,0x84,0x55,0x07,0x30,0x4f,0xe3,0xa9,
694 0x8d,0xc6,0xe9,0xb9,0x81,0x5d,0x3c,0x1e,0x34,0x8e,0xfd,0x4c,0xa4,0xfa,0xaa,0x1a,
695 0x61,0x2a,0x90,0x4a,0x17,0x15,0xa2,0x63,0xfd,0xe2,0xb3,0xab,0x34,0x08,0x9f,0x22,
696 0x5d,0x73,0x84,0x51,0x55,0x37,0x10,0xd5,0x76,0x17,0x93,0x25,0x8d,0xd5,0x93,0x0e,
697 0x2a,0x52,0x0d,0x74,0xfb,0xe9,0x10,0x56,0x2f,0x72,0x8e,0x2f,0xf9,0xb3,0xdb,0x52,
698 0x4b,0x2d,0x4c,0xae,0xb5,0x5c,0x6c,0x3d,0x89,0x75,0xc3,0xfa,0x78,0x6c,0x6a,0x13,
699 0xba,0x4a,0x2f,0xc9,0xfe,0xa5,0x3e,0xc6,0xe9,0x62,0xd5,0x83,0x39,0xd4,0x67,0xb0,
700 0xc9,0xfb,0x4d,0x66,0x92,0x96,0x58,0x70,0x4e,0x09,0xa3,0x02,0x73,0x28,0x05,0xa9,
701 0x20,0xe7,0xb9,0x34,0x98,0x94,0x0c,0x33,0x8c,0xa4,0xd5,0x22,0xd3,0x2a,0x7d,0x93,
702 0x68,0xdd,0xcb,0x65,0x1a,0xb4,0x99,0x7e,0x5b,0x81,0xcb,0x9c,0xba,0x22,0x3a,0x93,
703 0x40,0xb8,0x70,0x0f,0xd7,0x39,0x42,0x34,0x77,0xe9,0x89,0x28,0x2d,0xe7,0x6e,0x20,
704 0xb4,0xc1,0x2a,0x7d,0x9b,0x69,0x3e,0xbc,0xf4,0xf5,0xf4,0x7c,0x31,0xf2,0x0b,0x15,
705 0x8c,0x0b,0x21,0x08,0x47,0xd9,0xd2,0xae,0xd2,0xa6,0x59,0xfb,0x36,0x06,0xc6,0xb1,
706 0x38,0x8d,0x30,0x6c,0xb7,0xc3,0x8f,0x64,0xb3,0x1f,0xfa,0xd3,0xd1,0xc9,0x24,0xd9,
707 0xf4,0xd3,0x21,0x44,0x9d,0x74,0x7d,0xcd,0xc6,0xb9,0xd2,0xba,0x5e,0x99,0x77,0x00,
708 0x42,0x72,0x8b,0x99,0x07,0x68,0x05,0x27,0x52,0xed,0x07,0xb6,0xf6,0x6a,0xd3,0x1f,
709 0xd8,0xf4,0xd5,0xb6,0xaf,0x6d,0x81,0x11,0x72,0x04,0x78,0x15,0x42,0x7e,0xff,0x85,
710 0xee,0x26,0x78,0x52,0x69,0xd0,0x73,0xf4,0xd5,0x78,0x5a,0x8d,0x6d,0x6f,0xa1,0x40,
711 0x3c,0xcb,0x5c,0x61,0x2f,0x67,0xec,0xe0,0x5c,0x1b,0xe8,0x7a,0x57,0x9a,0x51,0x77,
712 0x8e,0xeb,0x30,0x4c,0xd6,0x9d,0xf7,0xe5,0x88,0xe5,0xc2,0xc3,0x38,0x0f,0xc3,0xcc,
713 0xf4,0x7c,0x84,0xc2,0x33,0xac,0xd2,0x20,0x43,0xb0,0xd3,0x6e,0x9b,0x95,0xe3,0x30,
714 0x88,0xc0,0xbc,0xb7,0xdc,0xf2,0x8e,0xff,0x98,0x77,0xf2,0xc9,0xbc,0x3b,0x98,0x31,
715 0x94,0x3c,0x67,0x8e,0xfb,0x8c,0x49,0xc0,0xd2,0x20,0xcc,0x40,0x0b,0x69,0x08,0x35,
716 0xbc,0x92,0xc2,0x7d,0x25,0x66,0xff,0x9e,0x77,0x60,0x19,0xa6,0xd6,0xd2,0x4c,0xd3,
717 0x8a,0x72,0x6b,0x44,0x25,0x01,0xa8,0x75,0xbf,0x81,0x81,0x32,0xd3,0xbc,0xd2,0xa2,
718 0xc4,0xc4,0xfe,0x13,0xef,0xf4,0xd3,0x78,0x47,0xf7,0xf1,0x8e,0xee,0xe3,0x1d,0xfd,
719 0x27,0xbc,0xe3,0xfc,0x5e,0xde,0xf1,0x3b,0xbc,0x3b,0x97,0xbf,0x6e,0x54,0x1a,0x2e,
720 0x9f,0x9f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0xe5,0xbe,0xed,0xcc,0x2a,0x10,0x73,
721 0x9e,0x84,0x13,0x2e,0x27,0xe1,0x8d,0x6f,0xf8,0x9e,0xae,0xd0,0x0a,0x8f,0x2a,0xca,
722 0xf7,0x78,0xda,0xcb,0xcf,0x4b,0x2d,0x29,0xcf,0x2f,0xc9,0x28,0x4a,0x4d,0xe5,0x02,
723 0x00,0x21,0x4c,0x04,0xbf,0x78,0xda,0x4b,0xcb,0x2f,0x2d,0x4a,0xcb,0x2c,0x4b,0x2d,
724 0xce,0xac,0xe0,0x02,0x00,0x20,0xfa,0x04,0xc5
725 };
726
727 enum enc {
728 GZIP,
729 BZIP2
730 };
731
verify(unsigned char * d,size_t s,void (* f1)(struct archive *,struct archive_entry *),void (* f2)(struct archive *,struct archive_entry *),enum enc etype)732 static void verify(unsigned char *d, size_t s,
733 void (*f1)(struct archive *, struct archive_entry *),
734 void (*f2)(struct archive *, struct archive_entry *),
735 enum enc etype)
736 {
737 struct archive_entry *ae;
738 struct archive *a;
739 unsigned char *buff;
740 int r;
741
742 assert((a = archive_read_new()) != NULL);
743 switch (etype) {
744 case BZIP2:
745 /* This is only check whether bzip is supported or not.
746 * This filter won't be used this test. */
747 if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
748 skipping("Unsupported bzip2");
749 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
750 return;
751 }
752 break;
753 case GZIP:
754 /* This gzip must be needed. archive_read_support_format_xar()
755 * will return a warning if gzip is unsupported. */
756 break;
757 }
758 assertA(0 == archive_read_support_filter_all(a));
759 r = archive_read_support_format_xar(a);
760 if (r == ARCHIVE_WARN) {
761 skipping("xar reading not fully supported on this platform");
762 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
763 return;
764 }
765 assert((buff = malloc(100000)) != NULL);
766 if (buff == NULL)
767 return;
768 memcpy(buff, d, s);
769 memset(buff + s, 0, 2048);
770
771 assertA(0 == archive_read_support_format_all(a));
772 assertA(0 == archive_read_open_memory(a, buff, s + 1024));
773 assertA(0 == archive_read_next_header(a, &ae));
774 assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE);
775 assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR);
776 assertEqualInt(archive_entry_is_encrypted(ae), 0);
777 assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
778 /* Verify the only entry. */
779 f1(a, ae);
780 if (f2) {
781 assertA(0 == archive_read_next_header(a, &ae));
782 assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE);
783 assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR);
784 /* Verify the only entry. */
785 f2(a, ae);
786 assertEqualInt(2, archive_file_count(a));
787 } else {
788 assertEqualInt(1, archive_file_count(a));
789 }
790 /* End of archive. */
791 assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
792
793 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
794 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
795 free(buff);
796 }
797
verifyB(unsigned char * d,size_t s)798 static void verifyB(unsigned char *d, size_t s) {
799 struct archive* a;
800 struct archive_entry *entry = NULL;
801 size_t buf_size;
802 unsigned char *buf;
803
804 assert((a = archive_read_new()) != NULL);
805
806 if(ARCHIVE_OK != archive_read_support_filter_gzip(a)) {
807 skipping("Unsupported gzip");
808 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
809 return;
810 }
811
812 if(ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
813 skipping("Unsupported bzip2");
814 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
815 return;
816 }
817
818 if(ARCHIVE_OK != archive_read_support_format_xar(a)) {
819 skipping("Unsupported xar");
820 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
821 return;
822 }
823
824 assertA(0 == archive_read_open_memory(a, d, s));
825
826 // f1, content "onetwothree\n", size 12 bytes
827 assertA(0 == archive_read_next_header(a, &entry));
828 buf_size = (size_t) archive_entry_size(entry);
829 assertA(buf_size == 12);
830 buf = malloc(buf_size);
831 assertA(NULL != buf);
832 assertA(buf_size == (size_t) archive_read_data(a, buf, buf_size));
833 free(buf);
834
835 // f2, content "fourfivesix\n", size 12 bytes
836 assertA(0 == archive_read_next_header(a, &entry));
837 buf_size = (size_t) archive_entry_size(entry);
838 assertA(buf_size == 12);
839 buf = malloc(buf_size);
840 assertA(NULL != buf);
841 assertA(buf_size == (size_t) archive_read_data(a, buf, buf_size));
842 free(buf);
843
844 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
845 }
846
DEFINE_TEST(test_read_format_xar)847 DEFINE_TEST(test_read_format_xar)
848 {
849 verify(archive1, sizeof(archive1), verify0, verify1, GZIP);
850 verify(archive2, sizeof(archive2), verify0, verify2, GZIP);
851 verify(archive3, sizeof(archive3), verify3, NULL, GZIP);
852 verify(archive4, sizeof(archive4), verify4, NULL, GZIP);
853 verify(archive5, sizeof(archive5), verify5, NULL, GZIP);
854 verify(archive6, sizeof(archive6), verify6, NULL, GZIP);
855 verify(archive7, sizeof(archive7), verify7, NULL, GZIP);
856 verify(archive8, sizeof(archive8), verify0, NULL, BZIP2);
857 verify(archive9, sizeof(archive9), verify0, NULL, GZIP);
858 verify(archive10, sizeof(archive10), verify0, NULL, GZIP);
859 verify(archive11, sizeof(archive11), verify0, NULL, GZIP);
860 verify(archive12, sizeof(archive12), verify12, NULL, GZIP);
861 verifyB(archive13, sizeof(archive13));
862 }
863
DEFINE_TEST(test_read_format_xar_duplicate_filename_node)864 DEFINE_TEST(test_read_format_xar_duplicate_filename_node)
865 {
866 static const char *reffiles[] =
867 {
868 "test_read_format_xar_duplicate_filename_node.xar",
869 NULL
870 };
871 struct archive_entry *ae;
872 struct archive *a;
873 int r;
874
875 extract_reference_files(reffiles);
876 assert((a = archive_read_new()) != NULL);
877 assertA(0 == archive_read_support_filter_all(a));
878
879 r = archive_read_support_format_xar(a);
880 if (r == ARCHIVE_WARN) {
881 skipping("xar reading not fully supported on this platform");
882 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
883 return;
884 }
885
886 assertA(0 == archive_read_open_filenames(a, reffiles, 10240));
887
888 assertA(0 == archive_read_next_header(a, &ae));
889 assertEqualString("File", archive_entry_pathname(ae));
890
891 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
892 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
893 }
894