2 zip_open.c -- open zip archive by name
3 Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
5 This file is part of libzip, a library to manipulate ZIP archives.
6 The authors can be contacted at <libzip@nih.at>
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions
11 1. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
17 3. The names of the authors may not be used to endorse or promote
18 products derived from this software without specific prior
21 THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
22 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 static zip_t *_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error);
50 static zip_int64_t _zip_checkcons(zip_t *za, zip_cdir_t *cdir, zip_error_t *error);
51 static zip_cdir_t *_zip_find_central_dir(zip_t *za, zip_uint64_t len);
52 static exists_t _zip_file_exists(zip_source_t *src, zip_error_t *error);
53 static int _zip_headercomp(const zip_dirent_t *, const zip_dirent_t *);
54 static unsigned char *_zip_memmem(const unsigned char *, size_t, const unsigned char *, size_t);
55 static zip_cdir_t *_zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error);
56 static zip_cdir_t *_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error);
57 static zip_cdir_t *_zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error);
61 zip_open(const char *fn, int _flags, int *zep)
65 struct zip_error error;
67 zip_error_init(&error);
68 if ((src = zip_source_file_create(fn, 0, -1, &error)) == NULL) {
69 _zip_set_open_error(zep, &error, 0);
70 zip_error_fini(&error);
74 if ((za = zip_open_from_source(src, _flags, &error)) == NULL) {
76 _zip_set_open_error(zep, &error, 0);
77 zip_error_fini(&error);
81 zip_error_fini(&error);
87 zip_open_from_source(zip_source_t *src, int _flags, zip_error_t *error)
89 static zip_int64_t needed_support_read = -1;
90 static zip_int64_t needed_support_write = -1;
93 zip_int64_t supported;
96 if (_flags < 0 || src == NULL) {
97 zip_error_set(error, ZIP_ER_INVAL, 0);
100 flags = (unsigned int)_flags;
102 supported = zip_source_supports(src);
103 if (needed_support_read == -1) {
104 needed_support_read = zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_SEEK, ZIP_SOURCE_TELL, ZIP_SOURCE_STAT, -1);
105 needed_support_write = zip_source_make_command_bitmap(ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_REMOVE, -1);
107 if ((supported & needed_support_read) != needed_support_read) {
108 zip_error_set(error, ZIP_ER_OPNOTSUPP, 0);
111 if ((supported & needed_support_write) != needed_support_write) {
115 if ((flags & (ZIP_RDONLY|ZIP_TRUNCATE)) == (ZIP_RDONLY|ZIP_TRUNCATE)) {
116 zip_error_set(error, ZIP_ER_RDONLY, 0);
120 exists = _zip_file_exists(src, error);
126 if ((flags & ZIP_CREATE) == 0) {
127 zip_error_set(error, ZIP_ER_NOENT, 0);
130 return _zip_allocate_new(src, flags, error);
134 if (flags & ZIP_EXCL) {
135 zip_error_set(error, ZIP_ER_EXISTS, 0);
138 if (zip_source_open(src) < 0) {
139 _zip_error_set_from_source(error, src);
143 if (flags & ZIP_TRUNCATE) {
144 za = _zip_allocate_new(src, flags, error);
147 /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL, just like open() */
148 za = _zip_open(src, flags, error);
152 zip_source_close(src);
162 _zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error)
167 zip_uint64_t len, idx;
170 if (zip_source_stat(src, &st) < 0) {
171 _zip_error_set_from_source(error, src);
174 if ((st.valid & ZIP_STAT_SIZE) == 0) {
175 zip_error_set(error, ZIP_ER_SEEK, EOPNOTSUPP);
180 /* treat empty files as empty archives */
182 if ((za=_zip_allocate_new(src, flags, error)) == NULL) {
183 zip_source_free(src);
190 if ((za=_zip_allocate_new(src, flags, error)) == NULL) {
194 if ((cdir = _zip_find_central_dir(za, len)) == NULL) {
195 _zip_error_copy(error, &za->error);
196 /* keep src so discard does not get rid of it */
197 zip_source_keep(src);
202 za->entry = cdir->entry;
203 za->nentry = cdir->nentry;
204 za->nentry_alloc = cdir->nentry_alloc;
205 za->comment_orig = cdir->comment;
209 _zip_hash_reserve_capacity(za->names, za->nentry, &za->error);
211 for (idx = 0; idx < za->nentry; idx++) {
212 const zip_uint8_t *name = _zip_string_get(za->entry[idx].orig->filename, NULL, 0, error);
214 /* keep src so discard does not get rid of it */
215 zip_source_keep(src);
220 if (_zip_hash_add(za->names, name, idx, ZIP_FL_UNCHANGED, &za->error) == false) {
221 if (za->error.zip_err != ZIP_ER_EXISTS || (flags & ZIP_CHECKCONS)) {
222 _zip_error_copy(error, &za->error);
223 /* keep src so discard does not get rid of it */
224 zip_source_keep(src);
231 za->ch_flags = za->flags;
238 _zip_set_open_error(int *zep, const zip_error_t *err, int ze)
241 ze = zip_error_code_zip(err);
242 if (zip_error_system_type(err) == ZIP_ET_SYS) {
243 errno = zip_error_code_system(err);
253 tries to find a valid end-of-central-directory at the beginning of
254 buf, and then the corresponding central directory entries.
255 Returns a struct zip_cdir which contains the central directory
256 entries, or NULL if unsuccessful. */
259 _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error)
262 zip_uint16_t comment_len;
263 zip_uint64_t i, left;
264 zip_uint64_t eocd_offset = _zip_buffer_offset(buffer);
265 zip_buffer_t *cd_buffer;
267 if (_zip_buffer_left(buffer) < EOCDLEN) {
268 /* not enough bytes left for comment */
269 zip_error_set(error, ZIP_ER_NOZIP, 0);
273 /* check for end-of-central-dir magic */
274 if (memcmp(_zip_buffer_get(buffer, 4), EOCD_MAGIC, 4) != 0) {
275 zip_error_set(error, ZIP_ER_NOZIP, 0);
279 if (eocd_offset >= EOCD64LOCLEN && memcmp(_zip_buffer_data(buffer) + eocd_offset - EOCD64LOCLEN, EOCD64LOC_MAGIC, 4) == 0) {
280 _zip_buffer_set_offset(buffer, eocd_offset - EOCD64LOCLEN);
281 cd = _zip_read_eocd64(za->src, buffer, buf_offset, za->flags, error);
284 _zip_buffer_set_offset(buffer, eocd_offset);
285 cd = _zip_read_eocd(buffer, buf_offset, za->flags, error);
291 _zip_buffer_set_offset(buffer, eocd_offset + 20);
292 comment_len = _zip_buffer_get_16(buffer);
294 if (cd->offset + cd->size > buf_offset + eocd_offset) {
295 /* cdir spans past EOCD record */
296 zip_error_set(error, ZIP_ER_INCONS, 0);
301 if (comment_len || (za->open_flags & ZIP_CHECKCONS)) {
302 zip_uint64_t tail_len;
304 _zip_buffer_set_offset(buffer, eocd_offset + EOCDLEN);
305 tail_len = _zip_buffer_left(buffer);
307 if (tail_len < comment_len || ((za->open_flags & ZIP_CHECKCONS) && tail_len != comment_len)) {
308 zip_error_set(error, ZIP_ER_INCONS, 0);
314 if ((cd->comment=_zip_string_new(_zip_buffer_get(buffer, comment_len), comment_len, ZIP_FL_ENC_GUESS, error)) == NULL) {
321 if (cd->offset >= buf_offset) {
323 /* if buffer already read in, use it */
324 _zip_buffer_set_offset(buffer, cd->offset - buf_offset);
326 if ((data = _zip_buffer_get(buffer, cd->size)) == NULL) {
327 zip_error_set(error, ZIP_ER_INCONS, 0);
331 if ((cd_buffer = _zip_buffer_new(data, cd->size)) == NULL) {
332 zip_error_set(error, ZIP_ER_MEMORY, 0);
340 if (zip_source_seek(za->src, (zip_int64_t)cd->offset, SEEK_SET) < 0) {
341 _zip_error_set_from_source(error, za->src);
346 /* possible consistency check: cd->offset = len-(cd->size+cd->comment_len+EOCDLEN) ? */
347 if (zip_source_tell(za->src) != (zip_int64_t)cd->offset) {
348 zip_error_set(error, ZIP_ER_NOZIP, 0);
354 left = (zip_uint64_t)cd->size;
358 zip_int64_t entry_size;
360 if (i == cd->nentry) {
361 /* InfoZIP has a hack to avoid using Zip64: it stores nentries % 0x10000 */
362 /* This hack isn't applicable if we're using Zip64, or if there is no central directory entry following. */
364 if (cd->is_zip64 || left < CDENTRYSIZE) {
368 if (!_zip_cdir_grow(cd, 0x10000, error)) {
370 _zip_buffer_free(cd_buffer);
376 if ((cd->entry[i].orig=_zip_dirent_new()) == NULL || (entry_size = _zip_dirent_read(cd->entry[i].orig, za->src, cd_buffer, false, error)) < 0) {
377 if (grown && zip_error_code_zip(error) == ZIP_ER_NOZIP) {
378 zip_error_set(error, ZIP_ER_INCONS, 0);
381 _zip_buffer_free(cd_buffer);
385 left -= (zip_uint64_t)entry_size;
388 if (i != cd->nentry || left > 0) {
389 zip_error_set(error, ZIP_ER_INCONS, 0);
390 _zip_buffer_free(cd_buffer);
395 if (za->open_flags & ZIP_CHECKCONS) {
399 ok = _zip_buffer_eof(cd_buffer);
402 zip_int64_t offset = zip_source_tell(za->src);
405 _zip_error_set_from_source(error, za->src);
409 ok = ((zip_uint64_t)offset == cd->offset + cd->size);
413 zip_error_set(error, ZIP_ER_INCONS, 0);
414 _zip_buffer_free(cd_buffer);
420 _zip_buffer_free(cd_buffer);
426 Checks the consistency of the central directory by comparing central
427 directory entries with local headers and checking for plausible
428 file and header offsets. Returns -1 if not plausible, else the
429 difference between the lowest and the highest fileposition reached */
432 _zip_checkcons(zip_t *za, zip_cdir_t *cd, zip_error_t *error)
435 zip_uint64_t min, max, j;
436 struct zip_dirent temp;
438 _zip_dirent_init(&temp);
440 max = cd->entry[0].orig->offset;
441 min = cd->entry[0].orig->offset;
446 for (i=0; i<cd->nentry; i++) {
447 if (cd->entry[i].orig->offset < min)
448 min = cd->entry[i].orig->offset;
449 if (min > (zip_uint64_t)cd->offset) {
450 zip_error_set(error, ZIP_ER_NOZIP, 0);
454 j = cd->entry[i].orig->offset + cd->entry[i].orig->comp_size
455 + _zip_string_length(cd->entry[i].orig->filename) + LENTRYSIZE;
458 if (max > (zip_uint64_t)cd->offset) {
459 zip_error_set(error, ZIP_ER_NOZIP, 0);
463 if (zip_source_seek(za->src, (zip_int64_t)cd->entry[i].orig->offset, SEEK_SET) < 0) {
464 _zip_error_set_from_source(error, za->src);
468 if (_zip_dirent_read(&temp, za->src, NULL, true, error) == -1) {
469 _zip_dirent_finalize(&temp);
473 if (_zip_headercomp(cd->entry[i].orig, &temp) != 0) {
474 zip_error_set(error, ZIP_ER_INCONS, 0);
475 _zip_dirent_finalize(&temp);
479 cd->entry[i].orig->extra_fields = _zip_ef_merge(cd->entry[i].orig->extra_fields, temp.extra_fields);
480 cd->entry[i].orig->local_extra_fields_read = 1;
481 temp.extra_fields = NULL;
483 _zip_dirent_finalize(&temp);
486 return (max-min) < ZIP_INT64_MAX ? (zip_int64_t)(max-min) : ZIP_INT64_MAX;
491 compares a central directory entry and a local file header
492 Return 0 if they are consistent, -1 if not. */
495 _zip_headercomp(const zip_dirent_t *central, const zip_dirent_t *local)
497 if ((central->version_needed < local->version_needed)
499 /* some zip-files have different values in local
500 and global headers for the bitflags */
501 || (central->bitflags != local->bitflags)
503 || (central->comp_method != local->comp_method)
504 || (central->last_mod != local->last_mod)
505 || !_zip_string_equal(central->filename, local->filename))
508 if ((central->crc != local->crc) || (central->comp_size != local->comp_size)
509 || (central->uncomp_size != local->uncomp_size)) {
510 /* InfoZip stores valid values in local header even when data descriptor is used.
511 This is in violation of the appnote. */
512 if (((local->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0
513 || local->crc != 0 || local->comp_size != 0 || local->uncomp_size != 0))
522 _zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error)
526 if ((za = _zip_new(error)) == NULL) {
531 za->open_flags = flags;
532 if (flags & ZIP_RDONLY) {
533 za->flags |= ZIP_AFL_RDONLY;
534 za->ch_flags |= ZIP_AFL_RDONLY;
541 * tests for file existence
544 _zip_file_exists(zip_source_t *src, zip_error_t *error)
549 if (zip_source_stat(src, &st) != 0) {
550 zip_error_t *src_error = zip_source_error(src);
551 if (zip_error_code_zip(src_error) == ZIP_ER_READ && zip_error_code_system(src_error) == ENOENT) {
554 _zip_error_copy(error, src_error);
558 return (st.valid & ZIP_STAT_SIZE) && st.size == 0 ? EXISTS_EMPTY : EXISTS_NONEMPTY;
563 _zip_find_central_dir(zip_t *za, zip_uint64_t len)
565 zip_cdir_t *cdir, *cdirnew;
567 zip_int64_t buf_offset;
572 zip_buffer_t *buffer;
575 zip_error_set(&za->error, ZIP_ER_NOZIP, 0);
579 buflen = (len < CDBUFSIZE ? len : CDBUFSIZE);
580 if (zip_source_seek(za->src, -(zip_int64_t)buflen, SEEK_END) < 0) {
581 zip_error_t *src_error = zip_source_error(za->src);
582 if (zip_error_code_zip(src_error) != ZIP_ER_SEEK || zip_error_code_system(src_error) != EFBIG) {
583 /* seek before start of file on my machine */
584 _zip_error_copy(&za->error, src_error);
588 if ((buf_offset = zip_source_tell(za->src)) < 0) {
589 _zip_error_set_from_source(&za->error, za->src);
593 if ((buffer = _zip_buffer_new_from_source(za->src, buflen, NULL, &za->error)) == NULL) {
599 if (buflen >= CDBUFSIZE) {
600 /* EOCD64 locator is before EOCD, so leave place for it */
601 _zip_buffer_set_offset(buffer, EOCD64LOCLEN);
603 zip_error_set(&error, ZIP_ER_NOZIP, 0);
605 match = _zip_buffer_get(buffer, 0);
606 while ((match=_zip_memmem(match, _zip_buffer_left(buffer)-(EOCDLEN-4), (const unsigned char *)EOCD_MAGIC, 4)) != NULL) {
607 _zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer)));
608 if ((cdirnew = _zip_read_cdir(za, buffer, (zip_uint64_t)buf_offset, &error)) != NULL) {
611 best = _zip_checkcons(za, cdir, &error);
614 a = _zip_checkcons(za, cdirnew, &error);
616 _zip_cdir_free(cdir);
621 _zip_cdir_free(cdirnew);
626 if (za->open_flags & ZIP_CHECKCONS)
627 best = _zip_checkcons(za, cdir, &error);
636 _zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer)));
639 _zip_buffer_free(buffer);
642 _zip_error_copy(&za->error, &error);
643 _zip_cdir_free(cdir);
651 static unsigned char *
652 _zip_memmem(const unsigned char *big, size_t biglen, const unsigned char *little, size_t littlelen)
654 const unsigned char *p;
656 if ((biglen < littlelen) || (littlelen == 0))
659 while ((p=(const unsigned char *)
660 memchr(p+1, little[0], (size_t)(big-(p+1))+(size_t)(biglen-littlelen)+1)) != NULL) {
661 if (memcmp(p+1, little+1, littlelen-1)==0)
662 return (unsigned char *)p;
670 _zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error)
673 zip_uint64_t i, nentry, size, offset, eocd_offset;
675 if (_zip_buffer_left(buffer) < EOCDLEN) {
676 zip_error_set(error, ZIP_ER_INCONS, 0);
680 eocd_offset = _zip_buffer_offset(buffer);
682 _zip_buffer_get(buffer, 4); /* magic already verified */
684 if (_zip_buffer_get_32(buffer) != 0) {
685 zip_error_set(error, ZIP_ER_MULTIDISK, 0);
689 /* number of cdir-entries on this disk */
690 i = _zip_buffer_get_16(buffer);
691 /* number of cdir-entries */
692 nentry = _zip_buffer_get_16(buffer);
695 zip_error_set(error, ZIP_ER_NOZIP, 0);
699 size = _zip_buffer_get_32(buffer);
700 offset = _zip_buffer_get_32(buffer);
702 if (offset+size < offset) {
703 zip_error_set(error, ZIP_ER_SEEK, EFBIG);
707 if (offset+size > buf_offset + eocd_offset) {
708 /* cdir spans past EOCD record */
709 zip_error_set(error, ZIP_ER_INCONS, 0);
713 if ((flags & ZIP_CHECKCONS) && offset+size != buf_offset + eocd_offset) {
714 zip_error_set(error, ZIP_ER_INCONS, 0);
718 if ((cd=_zip_cdir_new(nentry, error)) == NULL)
721 cd->is_zip64 = false;
730 _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error)
734 zip_uint8_t eocd[EOCD64LEN];
735 zip_uint64_t eocd_offset;
736 zip_uint64_t size, nentry, i, eocdloc_offset;
738 zip_uint32_t num_disks, num_disks64, eocd_disk, eocd_disk64;
740 eocdloc_offset = _zip_buffer_offset(buffer);
742 _zip_buffer_get(buffer, 4); /* magic already verified */
744 num_disks = _zip_buffer_get_16(buffer);
745 eocd_disk = _zip_buffer_get_16(buffer);
746 eocd_offset = _zip_buffer_get_64(buffer);
748 if (eocd_offset > ZIP_INT64_MAX || eocd_offset + EOCD64LEN < eocd_offset) {
749 zip_error_set(error, ZIP_ER_SEEK, EFBIG);
753 if (eocd_offset + EOCD64LEN > eocdloc_offset + buf_offset) {
754 zip_error_set(error, ZIP_ER_INCONS, 0);
758 if (eocd_offset >= buf_offset && eocd_offset + EOCD64LEN <= buf_offset + _zip_buffer_size(buffer)) {
759 _zip_buffer_set_offset(buffer, eocd_offset - buf_offset);
763 if (zip_source_seek(src, (zip_int64_t)eocd_offset, SEEK_SET) < 0) {
764 _zip_error_set_from_source(error, src);
767 if ((buffer = _zip_buffer_new_from_source(src, EOCD64LEN, eocd, error)) == NULL) {
773 if (memcmp(_zip_buffer_get(buffer, 4), EOCD64_MAGIC, 4) != 0) {
774 zip_error_set(error, ZIP_ER_INCONS, 0);
776 _zip_buffer_free(buffer);
781 size = _zip_buffer_get_64(buffer);
783 if ((flags & ZIP_CHECKCONS) && size + eocd_offset + 12 != buf_offset + eocdloc_offset) {
784 zip_error_set(error, ZIP_ER_INCONS, 0);
786 _zip_buffer_free(buffer);
791 _zip_buffer_get(buffer, 4); /* skip version made by/needed */
793 num_disks64 = _zip_buffer_get_32(buffer);
794 eocd_disk64 = _zip_buffer_get_32(buffer);
796 /* if eocd values are 0xffff, we have to use eocd64 values.
797 otherwise, if the values are not the same, it's inconsistent;
798 in any case, if the value is not 0, we don't support it */
799 if (num_disks == 0xffff) {
800 num_disks = num_disks64;
802 if (eocd_disk == 0xffff) {
803 eocd_disk = eocd_disk64;
805 if ((flags & ZIP_CHECKCONS) && (eocd_disk != eocd_disk64 || num_disks != num_disks64)) {
806 zip_error_set(error, ZIP_ER_INCONS, 0);
808 _zip_buffer_free(buffer);
812 if (num_disks != 0 || eocd_disk != 0) {
813 zip_error_set(error, ZIP_ER_MULTIDISK, 0);
815 _zip_buffer_free(buffer);
820 nentry = _zip_buffer_get_64(buffer);
821 i = _zip_buffer_get_64(buffer);
824 zip_error_set(error, ZIP_ER_MULTIDISK, 0);
826 _zip_buffer_free(buffer);
831 size = _zip_buffer_get_64(buffer);
832 offset = _zip_buffer_get_64(buffer);
834 if (!_zip_buffer_ok(buffer)) {
835 zip_error_set(error, ZIP_ER_INTERNAL, 0);
837 _zip_buffer_free(buffer);
843 _zip_buffer_free(buffer);
846 if (offset > ZIP_INT64_MAX || offset+size < offset) {
847 zip_error_set(error, ZIP_ER_SEEK, EFBIG);
850 if (offset+size > buf_offset + eocd_offset) {
851 /* cdir spans past EOCD record */
852 zip_error_set(error, ZIP_ER_INCONS, 0);
855 if ((flags & ZIP_CHECKCONS) && offset+size != buf_offset + eocd_offset) {
856 zip_error_set(error, ZIP_ER_INCONS, 0);
860 if ((cd=_zip_cdir_new(nentry, error)) == NULL)