blob: ee440d2385723262d85d5ead74b0395205a95187 [file] [log] [blame]
Dieter Baron659721f2017-12-04 17:16:46 +01001#include "zip.h"
2
Thomas Klausner00b3e342020-04-19 16:55:20 +02003#include <sys/stat.h>
4
Thomas Klausner8eab1a22018-01-15 14:10:11 +01005#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b))
Dieter Baron983d3a92017-12-10 13:21:07 +01006
Dieter Baron659721f2017-12-04 17:16:46 +01007#define FOR_REGRESS
8
Thomas Klausner8eab1a22018-01-15 14:10:11 +01009typedef enum { SOURCE_TYPE_NONE, SOURCE_TYPE_IN_MEMORY, SOURCE_TYPE_HOLE } source_type_t;
Dieter Baron659721f2017-12-04 17:16:46 +010010
11source_type_t source_type = SOURCE_TYPE_NONE;
Dieter Baron983d3a92017-12-10 13:21:07 +010012zip_uint64_t fragment_size = 0;
Dieter Baron659721f2017-12-04 17:16:46 +010013
14static int add_nul(int argc, char *argv[]);
Thomas Klausnera5761222020-01-07 11:59:25 +010015static int cancel(int argc, char *argv[]);
Thomas Klausner1e517752020-12-21 00:11:31 +010016static int unchange_one(int argc, char *argv[]);
Dieter Baron659721f2017-12-04 17:16:46 +010017static int unchange_all(int argc, char *argv[]);
18static int zin_close(int argc, char *argv[]);
19
Dieter Baron983d3a92017-12-10 13:21:07 +010020#define OPTIONS_REGRESS "F:Hm"
Dieter Baron659721f2017-12-04 17:16:46 +010021
Dieter Baron983d3a92017-12-10 13:21:07 +010022#define USAGE_REGRESS " [-Hm] [-F fragment-size]"
Dieter Baron659721f2017-12-04 17:16:46 +010023
Thomas Klausner8eab1a22018-01-15 14:10:11 +010024#define GETOPT_REGRESS \
25 case 'H': \
Thomas Klausnera14fded2020-07-21 16:07:23 +020026 source_type = SOURCE_TYPE_HOLE; \
27 break; \
Thomas Klausner8eab1a22018-01-15 14:10:11 +010028 case 'm': \
Thomas Klausnera14fded2020-07-21 16:07:23 +020029 source_type = SOURCE_TYPE_IN_MEMORY; \
30 break; \
Thomas Klausner8eab1a22018-01-15 14:10:11 +010031 case 'F': \
Thomas Klausnera14fded2020-07-21 16:07:23 +020032 fragment_size = strtoull(optarg, NULL, 10); \
33 break;
Dieter Baron659721f2017-12-04 17:16:46 +010034
Thomas Klausner47dc1fc2020-07-21 16:05:31 +020035/* clang-format off */
36
Dieter Baron659721f2017-12-04 17:16:46 +010037#define DISPATCH_REGRESS \
Thomas Klausnera5761222020-01-07 11:59:25 +010038 {"add_nul", 2, "name length", "add NUL bytes", add_nul}, \
39 {"cancel", 1, "limit", "cancel writing archive when limit% have been written (calls print_progress)", cancel}, \
Thomas Klausner1e517752020-12-21 00:11:31 +010040 {"unchange", 1, "index", "revert changes for entry", unchange_one}, \
Thomas Klausnera5761222020-01-07 11:59:25 +010041 {"unchange_all", 0, "", "revert all changes", unchange_all}, \
42 { "zin_close", 1, "index", "close input zip_source (for internal tests)", zin_close }
Dieter Baron659721f2017-12-04 17:16:46 +010043
Thomas Klausner47dc1fc2020-07-21 16:05:31 +020044/* clang-format on */
45
Dieter Baron659721f2017-12-04 17:16:46 +010046
47zip_t *ziptool_open(const char *archive, int flags, zip_error_t *error, zip_uint64_t offset, zip_uint64_t len);
Dieter Baron659721f2017-12-04 17:16:46 +010048
49
50#include "ziptool.c"
51
52
53zip_source_t *memory_src = NULL;
54
55zip_source_t *source_hole_create(const char *, int flags, zip_error_t *);
56
57static zip_t *read_to_memory(const char *archive, int flags, zip_error_t *error, zip_source_t **srcp);
58static zip_source_t *source_nul(zip_t *za, zip_uint64_t length);
59
60
61static int
62add_nul(int argc, char *argv[]) {
63 zip_source_t *zs;
64 zip_uint64_t length = strtoull(argv[1], NULL, 10);
65
Thomas Klausner8eab1a22018-01-15 14:10:11 +010066 if ((zs = source_nul(za, length)) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +020067 fprintf(stderr, "can't create zip_source for length: %s\n", zip_strerror(za));
68 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +010069 }
70
71 if (zip_add(za, argv[0], zs) == -1) {
Thomas Klausnera14fded2020-07-21 16:07:23 +020072 zip_source_free(zs);
73 fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za));
74 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +010075 }
76 return 0;
77}
78
79static int
80unchange_all(int argc, char *argv[]) {
81 if (zip_unchange_all(za) < 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +020082 fprintf(stderr, "can't revert changes to archive: %s\n", zip_strerror(za));
83 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +010084 }
85 return 0;
86}
87
Thomas Klausner1e517752020-12-21 00:11:31 +010088
89static int
90unchange_one(int argc, char *argv[]) {
91 zip_uint64_t idx;
92
93 idx = strtoull(argv[0], NULL, 10);
94
95 if (zip_unchange(za, idx) < 0) {
96 fprintf(stderr, "can't revert changes for entry %" PRIu64 ": %s", idx, zip_strerror(za));
97 return -1;
98 }
99
100 return 0;
101}
102
103
Dieter Baron659721f2017-12-04 17:16:46 +0100104static int
Thomas Klausnera5761222020-01-07 11:59:25 +0100105cancel_callback(zip_t *archive, void *ud) {
106 if (progress_userdata.percentage >= progress_userdata.limit) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200107 return -1;
Thomas Klausnera5761222020-01-07 11:59:25 +0100108 }
109 return 0;
110}
111
112static int
113cancel(int argc, char *argv[]) {
114 zip_int64_t percent;
115 percent = strtoll(argv[0], NULL, 10);
116 if (percent > 100 || percent < 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200117 fprintf(stderr, "invalid percentage '%" PRId64 "' for cancel (valid: 0 <= x <= 100)\n", percent);
118 return -1;
Thomas Klausnera5761222020-01-07 11:59:25 +0100119 }
Thomas Klausner29c6a392020-07-21 16:06:03 +0200120 progress_userdata.limit = ((double)percent) / 100;
Thomas Klausnera5761222020-01-07 11:59:25 +0100121
122 zip_register_cancel_callback_with_state(za, cancel_callback, NULL, NULL);
123
124 /* needs the percentage updates from print_progress */
125 print_progress(argc, argv);
126 return 0;
127}
128
129static int
Dieter Baron659721f2017-12-04 17:16:46 +0100130zin_close(int argc, char *argv[]) {
131 zip_uint64_t idx;
132
133 idx = strtoull(argv[0], NULL, 10);
134 if (idx >= z_in_count) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200135 fprintf(stderr, "invalid argument '%" PRIu64 "', only %u zip sources open\n", idx, z_in_count);
136 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100137 }
138 if (zip_close(z_in[idx]) < 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200139 fprintf(stderr, "can't close source archive: %s\n", zip_strerror(z_in[idx]));
140 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100141 }
142 z_in[idx] = z_in[z_in_count];
143 z_in_count--;
144
145 return 0;
146}
147
148
149static zip_t *
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100150read_hole(const char *archive, int flags, zip_error_t *error) {
Dieter Baron659721f2017-12-04 17:16:46 +0100151 zip_source_t *src = NULL;
152 zip_t *zs = NULL;
153
154 if (strcmp(archive, "/dev/stdin") == 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200155 zip_error_set(error, ZIP_ER_OPNOTSUPP, 0);
156 return NULL;
Dieter Baron659721f2017-12-04 17:16:46 +0100157 }
158
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100159 if ((src = source_hole_create(archive, flags, error)) == NULL || (zs = zip_open_from_source(src, flags, error)) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200160 zip_source_free(src);
Dieter Baron659721f2017-12-04 17:16:46 +0100161 }
162
163 return zs;
164}
165
166
167static zip_t *
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100168read_to_memory(const char *archive, int flags, zip_error_t *error, zip_source_t **srcp) {
Dieter Baron659721f2017-12-04 17:16:46 +0100169 zip_source_t *src;
170 zip_t *zb;
Dieter Baron79557342017-12-22 16:00:11 +0100171 FILE *fp;
Dieter Baron659721f2017-12-04 17:16:46 +0100172
173 if (strcmp(archive, "/dev/stdin") == 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200174 zip_error_set(error, ZIP_ER_OPNOTSUPP, 0);
175 return NULL;
Dieter Baron659721f2017-12-04 17:16:46 +0100176 }
177
Michał Janiszewskia9bf6162020-03-08 21:34:36 +0100178 if ((fp = fopen(archive, "rb")) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200179 if (errno == ENOENT) {
180 src = zip_source_buffer_create(NULL, 0, 0, error);
181 }
182 else {
183 zip_error_set(error, ZIP_ER_OPEN, errno);
184 return NULL;
185 }
Dieter Baron659721f2017-12-04 17:16:46 +0100186 }
187 else {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200188 struct stat st;
Dieter Baron983d3a92017-12-10 13:21:07 +0100189
Thomas Klausnera14fded2020-07-21 16:07:23 +0200190 if (fstat(fileno(fp), &st) < 0) {
191 fclose(fp);
192 zip_error_set(error, ZIP_ER_OPEN, errno);
193 return NULL;
194 }
195 if (fragment_size == 0) {
196 char *buf;
197 if ((buf = malloc((size_t)st.st_size)) == NULL) {
198 fclose(fp);
199 zip_error_set(error, ZIP_ER_MEMORY, 0);
200 return NULL;
201 }
202 if (fread(buf, (size_t)st.st_size, 1, fp) < 1) {
203 free(buf);
204 fclose(fp);
205 zip_error_set(error, ZIP_ER_READ, errno);
206 return NULL;
207 }
208 src = zip_source_buffer_create(buf, (zip_uint64_t)st.st_size, 1, error);
209 if (src == NULL) {
210 free(buf);
211 }
212 }
213 else {
214 zip_uint64_t nfragments, i, left;
215 zip_buffer_fragment_t *fragments;
Dieter Baron983d3a92017-12-10 13:21:07 +0100216
Thomas Klausnera14fded2020-07-21 16:07:23 +0200217 nfragments = ((size_t)st.st_size + fragment_size - 1) / fragment_size;
218 if ((fragments = malloc(sizeof(fragments[0]) * nfragments)) == NULL) {
219 fclose(fp);
220 zip_error_set(error, ZIP_ER_MEMORY, 0);
221 return NULL;
222 }
223 for (i = 0; i < nfragments; i++) {
224 left = ZIP_MIN(fragment_size, (size_t)st.st_size - i * fragment_size);
225 if ((fragments[i].data = malloc(left)) == NULL) {
Dieter Baronda9477f2018-02-17 12:16:03 +0100226#ifndef __clang_analyzer__
Thomas Klausnera14fded2020-07-21 16:07:23 +0200227 /* fragments is initialized up to i - 1*/
228 while (--i > 0) {
229 free(fragments[i].data);
230 }
Dieter Baronda9477f2018-02-17 12:16:03 +0100231#endif
Thomas Klausnera14fded2020-07-21 16:07:23 +0200232 free(fragments);
233 fclose(fp);
234 zip_error_set(error, ZIP_ER_MEMORY, 0);
235 return NULL;
236 }
237 fragments[i].length = left;
238 if (fread(fragments[i].data, left, 1, fp) < 1) {
Dieter Baronda9477f2018-02-17 12:16:03 +0100239#ifndef __clang_analyzer__
Thomas Klausnera14fded2020-07-21 16:07:23 +0200240 /* fragments is initialized up to i - 1*/
241 while (--i > 0) {
242 free(fragments[i].data);
243 }
Dieter Baronda9477f2018-02-17 12:16:03 +0100244#endif
Thomas Klausnera14fded2020-07-21 16:07:23 +0200245 free(fragments);
246 fclose(fp);
247 zip_error_set(error, ZIP_ER_READ, errno);
248 return NULL;
249 }
250 }
251 src = zip_source_buffer_fragment_create(fragments, nfragments, 1, error);
252 if (src == NULL) {
253 for (i = 0; i < nfragments; i++) {
254 free(fragments[i].data);
255 }
256 free(fragments);
257 fclose(fp);
258 return NULL;
259 }
260 free(fragments);
261 }
262 fclose(fp);
Dieter Baron659721f2017-12-04 17:16:46 +0100263 }
264 if (src == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200265 return NULL;
Dieter Baron659721f2017-12-04 17:16:46 +0100266 }
267 zb = zip_open_from_source(src, flags, error);
268 if (zb == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200269 zip_source_free(src);
270 return NULL;
Dieter Baron659721f2017-12-04 17:16:46 +0100271 }
272 zip_source_keep(src);
273 *srcp = src;
274 return zb;
275}
276
277
278typedef struct source_nul {
279 zip_error_t error;
280 zip_uint64_t length;
281 zip_uint64_t offset;
282} source_nul_t;
283
284static zip_int64_t
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100285source_nul_cb(void *ud, void *data, zip_uint64_t length, zip_source_cmd_t command) {
Dieter Baron659721f2017-12-04 17:16:46 +0100286 source_nul_t *ctx = (source_nul_t *)ud;
287
288 switch (command) {
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100289 case ZIP_SOURCE_CLOSE:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200290 return 0;
Dieter Baron659721f2017-12-04 17:16:46 +0100291
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100292 case ZIP_SOURCE_ERROR:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200293 return zip_error_to_data(&ctx->error, data, length);
Dieter Baron659721f2017-12-04 17:16:46 +0100294
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100295 case ZIP_SOURCE_FREE:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200296 free(ctx);
297 return 0;
Dieter Baron659721f2017-12-04 17:16:46 +0100298
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100299 case ZIP_SOURCE_OPEN:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200300 ctx->offset = 0;
301 return 0;
Dieter Baron659721f2017-12-04 17:16:46 +0100302
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100303 case ZIP_SOURCE_READ:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200304 if (length > ZIP_INT64_MAX) {
305 zip_error_set(&ctx->error, ZIP_ER_INVAL, 0);
306 return -1;
307 }
Dieter Baron659721f2017-12-04 17:16:46 +0100308
Thomas Klausnera14fded2020-07-21 16:07:23 +0200309 if (length > ctx->length - ctx->offset) {
310 length = ctx->length - ctx->offset;
311 }
Dieter Baron659721f2017-12-04 17:16:46 +0100312
Thomas Klausnera14fded2020-07-21 16:07:23 +0200313 memset(data, 0, length);
314 ctx->offset += length;
315 return (zip_int64_t)length;
Dieter Baron659721f2017-12-04 17:16:46 +0100316
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100317 case ZIP_SOURCE_STAT: {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200318 zip_stat_t *st = ZIP_SOURCE_GET_ARGS(zip_stat_t, data, length, &ctx->error);
Dieter Baron659721f2017-12-04 17:16:46 +0100319
Thomas Klausnera14fded2020-07-21 16:07:23 +0200320 if (st == NULL) {
321 return -1;
322 }
Dieter Baron659721f2017-12-04 17:16:46 +0100323
Thomas Klausnera14fded2020-07-21 16:07:23 +0200324 st->valid |= ZIP_STAT_SIZE;
325 st->size = ctx->length;
Dieter Baron659721f2017-12-04 17:16:46 +0100326
Thomas Klausnera14fded2020-07-21 16:07:23 +0200327 return 0;
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100328 }
Dieter Baron659721f2017-12-04 17:16:46 +0100329
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100330 case ZIP_SOURCE_SUPPORTS:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200331 return zip_source_make_command_bitmap(ZIP_SOURCE_CLOSE, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_STAT, -1);
Dieter Baron659721f2017-12-04 17:16:46 +0100332
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100333 default:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200334 zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0);
335 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100336 }
337}
338
339static zip_source_t *
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100340source_nul(zip_t *zs, zip_uint64_t length) {
Dieter Baron659721f2017-12-04 17:16:46 +0100341 source_nul_t *ctx;
342 zip_source_t *src;
343
344 if ((ctx = (source_nul_t *)malloc(sizeof(*ctx))) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200345 zip_error_set(zip_get_error(zs), ZIP_ER_MEMORY, 0);
346 return NULL;
Dieter Baron659721f2017-12-04 17:16:46 +0100347 }
348
349 zip_error_init(&ctx->error);
350 ctx->length = length;
351 ctx->offset = 0;
352
353 if ((src = zip_source_function(zs, source_nul_cb, ctx)) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200354 free(ctx);
355 return NULL;
Dieter Baron659721f2017-12-04 17:16:46 +0100356 }
357
358 return src;
359}
360
361
362static int
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100363write_memory_src_to_file(const char *archive, zip_source_t *src) {
Dieter Baron659721f2017-12-04 17:16:46 +0100364 zip_stat_t zst;
365 char *buf;
366 FILE *fp;
367
368 if (zip_source_stat(src, &zst) < 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200369 fprintf(stderr, "zip_source_stat on buffer failed: %s\n", zip_error_strerror(zip_source_error(src)));
370 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100371 }
372 if (zip_source_open(src) < 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200373 if (zip_error_code_zip(zip_source_error(src)) == ZIP_ER_DELETED) {
374 if (unlink(archive) < 0 && errno != ENOENT) {
375 fprintf(stderr, "unlink failed: %s\n", strerror(errno));
376 return -1;
377 }
378 return 0;
379 }
380 fprintf(stderr, "zip_source_open on buffer failed: %s\n", zip_error_strerror(zip_source_error(src)));
381 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100382 }
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100383 if ((buf = malloc(zst.size)) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200384 fprintf(stderr, "malloc failed: %s\n", strerror(errno));
385 zip_source_close(src);
386 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100387 }
388 if (zip_source_read(src, buf, zst.size) < (zip_int64_t)zst.size) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200389 fprintf(stderr, "zip_source_read on buffer failed: %s\n", zip_error_strerror(zip_source_error(src)));
390 zip_source_close(src);
391 free(buf);
392 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100393 }
394 zip_source_close(src);
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100395 if ((fp = fopen(archive, "wb")) == NULL) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200396 fprintf(stderr, "fopen failed: %s\n", strerror(errno));
397 free(buf);
398 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100399 }
400 if (fwrite(buf, zst.size, 1, fp) < 1) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200401 fprintf(stderr, "fwrite failed: %s\n", strerror(errno));
402 free(buf);
403 fclose(fp);
404 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100405 }
406 free(buf);
407 if (fclose(fp) != 0) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200408 fprintf(stderr, "fclose failed: %s\n", strerror(errno));
409 return -1;
Dieter Baron659721f2017-12-04 17:16:46 +0100410 }
411 return 0;
412}
413
414
415zip_t *
416ziptool_open(const char *archive, int flags, zip_error_t *error, zip_uint64_t offset, zip_uint64_t len) {
417 switch (source_type) {
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100418 case SOURCE_TYPE_NONE:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200419 za = read_from_file(archive, flags, error, offset, len);
420 break;
Dieter Baron659721f2017-12-04 17:16:46 +0100421
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100422 case SOURCE_TYPE_IN_MEMORY:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200423 za = read_to_memory(archive, flags, error, &memory_src);
424 break;
Dieter Baron659721f2017-12-04 17:16:46 +0100425
Thomas Klausner8eab1a22018-01-15 14:10:11 +0100426 case SOURCE_TYPE_HOLE:
Thomas Klausnera14fded2020-07-21 16:07:23 +0200427 za = read_hole(archive, flags, error);
428 break;
Dieter Baron659721f2017-12-04 17:16:46 +0100429 }
430
431 return za;
432}
433
434
435int
436ziptool_post_close(const char *archive) {
437 if (source_type == SOURCE_TYPE_IN_MEMORY) {
Thomas Klausnera14fded2020-07-21 16:07:23 +0200438 if (write_memory_src_to_file(archive, memory_src) < 0) {
439 return -1;
440 }
441 zip_source_free(memory_src);
Dieter Baron659721f2017-12-04 17:16:46 +0100442 }
443
444 return 0;
445}