Rizin
unix-like reverse engineering framework and cli tools
zip_dirent.c
Go to the documentation of this file.
1 /*
2  zip_dirent.c -- read directory entry (local or central), clean dirent
3  Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
4 
5  This file is part of libzip, a library to manipulate ZIP archives.
6  The authors can be contacted at <info@libzip.org>
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions
10  are met:
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
16  distribution.
17  3. The names of the authors may not be used to endorse or promote
18  products derived from this software without specific prior
19  written permission.
20 
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.
32 */
33 
34 
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <sys/types.h>
39 #include <time.h>
40 
41 #include "zipint.h"
42 
46 
47 
48 void
51 
52  if (!cd)
53  return;
54 
55  for (i = 0; i < cd->nentry; i++)
56  _zip_entry_finalize(cd->entry + i);
57  free(cd->entry);
58  _zip_string_free(cd->comment);
59  free(cd);
60 }
61 
62 
63 zip_cdir_t *
65  zip_cdir_t *cd;
66 
67  if ((cd = (zip_cdir_t *)malloc(sizeof(*cd))) == NULL) {
69  return NULL;
70  }
71 
72  cd->entry = NULL;
73  cd->nentry = cd->nentry_alloc = 0;
74  cd->size = cd->offset = 0;
75  cd->comment = NULL;
76  cd->is_zip64 = false;
77 
78  if (!_zip_cdir_grow(cd, nentry, error)) {
80  return NULL;
81  }
82 
83  return cd;
84 }
85 
86 
87 bool
89  zip_uint64_t i, new_alloc;
90  zip_entry_t *new_entry;
91 
92  if (additional_entries == 0) {
93  return true;
94  }
95 
96  new_alloc = cd->nentry_alloc + additional_entries;
97 
98  if (new_alloc < additional_entries || new_alloc > SIZE_MAX / sizeof(*(cd->entry))) {
100  return false;
101  }
102 
103  if ((new_entry = (zip_entry_t *)realloc(cd->entry, sizeof(*(cd->entry)) * (size_t)new_alloc)) == NULL) {
105  return false;
106  }
107 
108  cd->entry = new_entry;
109 
110  for (i = cd->nentry; i < new_alloc; i++) {
111  _zip_entry_init(cd->entry + i);
112  }
113 
114  cd->nentry = cd->nentry_alloc = new_alloc;
115 
116  return true;
117 }
118 
119 
121 _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors) {
123  zip_string_t *comment;
127  zip_uint64_t i;
128  bool is_zip64;
129  int ret;
130 
131  if ((off = zip_source_tell_write(za->src)) < 0) {
133  return -1;
134  }
136 
137  is_zip64 = false;
138 
139  for (i = 0; i < survivors; i++) {
140  zip_entry_t *entry = za->entry + filelist[i].idx;
141 
142  if ((ret = _zip_dirent_write(za, entry->changes ? entry->changes : entry->orig, ZIP_FL_CENTRAL)) < 0)
143  return -1;
144  if (ret)
145  is_zip64 = true;
146  }
147 
148  if ((off = zip_source_tell_write(za->src)) < 0) {
150  return -1;
151  }
153 
154  if (offset > ZIP_UINT32_MAX || survivors > ZIP_UINT16_MAX)
155  is_zip64 = true;
156 
157 
158  if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) {
160  return -1;
161  }
162 
163  if (is_zip64) {
170  _zip_buffer_put_64(buffer, survivors);
171  _zip_buffer_put_64(buffer, survivors);
178  }
179 
182  _zip_buffer_put_16(buffer, (zip_uint16_t)(survivors >= ZIP_UINT16_MAX ? ZIP_UINT16_MAX : survivors));
183  _zip_buffer_put_16(buffer, (zip_uint16_t)(survivors >= ZIP_UINT16_MAX ? ZIP_UINT16_MAX : survivors));
186 
188 
189  _zip_buffer_put_16(buffer, (zip_uint16_t)(comment ? comment->length : 0));
190 
191  if (!_zip_buffer_ok(buffer)) {
194  return -1;
195  }
196 
199  return -1;
200  }
201 
203 
204  if (comment) {
205  if (_zip_write(za, comment->raw, comment->length) < 0) {
206  return -1;
207  }
208  }
209 
210  return (zip_int64_t)size;
211 }
212 
213 
214 zip_dirent_t *
216  zip_dirent_t *tde;
217 
218  if ((tde = (zip_dirent_t *)malloc(sizeof(*tde))) == NULL)
219  return NULL;
220 
221  if (sde)
222  memcpy(tde, sde, sizeof(*sde));
223  else
224  _zip_dirent_init(tde);
225 
226  tde->changed = 0;
227  tde->cloned = 1;
228 
229  return tde;
230 }
231 
232 
233 void
235  if (!zde->cloned || zde->changed & ZIP_DIRENT_FILENAME) {
237  zde->filename = NULL;
238  }
239  if (!zde->cloned || zde->changed & ZIP_DIRENT_EXTRA_FIELD) {
241  zde->extra_fields = NULL;
242  }
243  if (!zde->cloned || zde->changed & ZIP_DIRENT_COMMENT) {
245  zde->comment = NULL;
246  }
247  if (!zde->cloned || zde->changed & ZIP_DIRENT_PASSWORD) {
248  if (zde->password) {
249  _zip_crypto_clear(zde->password, strlen(zde->password));
250  }
251  free(zde->password);
252  zde->password = NULL;
253  }
254 }
255 
256 
257 void
259  if (zde == NULL)
260  return;
261 
263  free(zde);
264 }
265 
266 
267 void
269  de->changed = 0;
270  de->local_extra_fields_read = 0;
271  de->cloned = 0;
272 
273  de->crc_valid = true;
274  de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8);
275  de->version_needed = 10; /* 1.0 */
276  de->bitflags = 0;
278  de->last_mod = 0;
279  de->crc = 0;
280  de->comp_size = 0;
281  de->uncomp_size = 0;
282  de->filename = NULL;
283  de->extra_fields = NULL;
284  de->comment = NULL;
285  de->disk_number = 0;
286  de->int_attrib = 0;
288  de->offset = 0;
289  de->compression_level = 0;
291  de->password = NULL;
292 }
293 
294 
295 bool
298  return true;
299 
300  return false;
301 }
302 
303 
304 zip_dirent_t *
306  zip_dirent_t *de;
307 
308  if ((de = (zip_dirent_t *)malloc(sizeof(*de))) == NULL)
309  return NULL;
310 
311  _zip_dirent_init(de);
312  return de;
313 }
314 
315 
316 /* _zip_dirent_read(zde, fp, bufp, left, localp, error):
317  Fills the zip directory entry zde.
318 
319  If buffer is non-NULL, data is taken from there; otherwise data is read from fp as needed.
320 
321  If local is true, it reads a local header instead of a central directory entry.
322 
323  Returns size of dirent read if successful. On error, error is filled in and -1 is returned.
324 */
325 
329  zip_uint16_t dostime, dosdate;
330  zip_uint32_t size, variable_size;
331  zip_uint16_t filename_len, comment_len, ef_len;
332 
333  bool from_buffer = (buffer != NULL);
334 
336 
337  if (buffer) {
338  if (_zip_buffer_left(buffer) < size) {
340  return -1;
341  }
342  }
343  else {
345  return -1;
346  }
347  }
348 
349  if (memcmp(_zip_buffer_get(buffer, 4), (local ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
351  if (!from_buffer) {
353  }
354  return -1;
355  }
356 
357  /* convert buffercontents to zip_dirent */
358 
359  _zip_dirent_init(zde);
360  if (!local)
362  else
363  zde->version_madeby = 0;
367 
368  /* convert to time_t */
369  dostime = _zip_buffer_get_16(buffer);
370  dosdate = _zip_buffer_get_16(buffer);
371  zde->last_mod = _zip_d2u_time(dostime, dosdate);
372 
373  zde->crc = _zip_buffer_get_32(buffer);
376 
377  filename_len = _zip_buffer_get_16(buffer);
378  ef_len = _zip_buffer_get_16(buffer);
379 
380  if (local) {
381  comment_len = 0;
382  zde->disk_number = 0;
383  zde->int_attrib = 0;
384  zde->ext_attrib = 0;
385  zde->offset = 0;
386  }
387  else {
388  comment_len = _zip_buffer_get_16(buffer);
393  }
394 
395  if (!_zip_buffer_ok(buffer)) {
397  if (!from_buffer) {
399  }
400  return -1;
401  }
402 
403  if (zde->bitflags & ZIP_GPBF_ENCRYPTED) {
405  /* TODO */
407  }
408  else {
410  }
411  }
412  else {
414  }
415 
416  zde->filename = NULL;
417  zde->extra_fields = NULL;
418  zde->comment = NULL;
419 
420  variable_size = (zip_uint32_t)filename_len + (zip_uint32_t)ef_len + (zip_uint32_t)comment_len;
421 
422  if (from_buffer) {
423  if (_zip_buffer_left(buffer) < variable_size) {
425  return -1;
426  }
427  }
428  else {
430 
431  if ((buffer = _zip_buffer_new_from_source(src, variable_size, NULL, error)) == NULL) {
432  return -1;
433  }
434  }
435 
436  if (filename_len) {
437  zde->filename = _zip_read_string(buffer, src, filename_len, 1, error);
438  if (!zde->filename) {
441  }
442  if (!from_buffer) {
444  }
445  return -1;
446  }
447 
448  if (zde->bitflags & ZIP_GPBF_ENCODING_UTF_8) {
451  if (!from_buffer) {
453  }
454  return -1;
455  }
456  }
457  }
458 
459  if (ef_len) {
460  zip_uint8_t *ef = _zip_read_data(buffer, src, ef_len, 0, error);
461 
462  if (ef == NULL) {
463  if (!from_buffer) {
465  }
466  return -1;
467  }
468  if (!_zip_ef_parse(ef, ef_len, local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL, &zde->extra_fields, error)) {
469  free(ef);
470  if (!from_buffer) {
472  }
473  return -1;
474  }
475  free(ef);
476  if (local)
477  zde->local_extra_fields_read = 1;
478  }
479 
480  if (comment_len) {
481  zde->comment = _zip_read_string(buffer, src, comment_len, 0, error);
482  if (!zde->comment) {
483  if (!from_buffer) {
485  }
486  return -1;
487  }
488  if (zde->bitflags & ZIP_GPBF_ENCODING_UTF_8) {
491  if (!from_buffer) {
493  }
494  return -1;
495  }
496  }
497  }
498 
501 
502  /* Zip64 */
503 
504  if (zde->uncomp_size == ZIP_UINT32_MAX || zde->comp_size == ZIP_UINT32_MAX || zde->offset == ZIP_UINT32_MAX) {
505  zip_uint16_t got_len;
506  zip_buffer_t *ef_buffer;
508  /* TODO: if got_len == 0 && !ZIP64_EOCD: no error, 0xffffffff is valid value */
509  if (ef == NULL) {
510  if (!from_buffer) {
512  }
513  return -1;
514  }
515 
516  if ((ef_buffer = _zip_buffer_new((zip_uint8_t *)ef, got_len)) == NULL) {
518  if (!from_buffer) {
520  }
521  return -1;
522  }
523 
524  if (zde->uncomp_size == ZIP_UINT32_MAX) {
525  zde->uncomp_size = _zip_buffer_get_64(ef_buffer);
526  }
527  else if (local) {
528  /* From appnote.txt: This entry in the Local header MUST
529  include BOTH original and compressed file size fields. */
530  (void)_zip_buffer_skip(ef_buffer, 8); /* error is caught by _zip_buffer_eof() call */
531  }
532  if (zde->comp_size == ZIP_UINT32_MAX) {
533  zde->comp_size = _zip_buffer_get_64(ef_buffer);
534  }
535  if (!local) {
536  if (zde->offset == ZIP_UINT32_MAX) {
537  zde->offset = _zip_buffer_get_64(ef_buffer);
538  }
539  if (zde->disk_number == ZIP_UINT16_MAX) {
540  zde->disk_number = _zip_buffer_get_32(ef_buffer);
541  }
542  }
543 
544  if (!_zip_buffer_eof(ef_buffer)) {
545  /* accept additional fields if values match */
546  bool ok = true;
547  switch (got_len) {
548  case 28:
549  _zip_buffer_set_offset(ef_buffer, 24);
550  if (zde->disk_number != _zip_buffer_get_32(ef_buffer)) {
551  ok = false;
552  }
553  /* fallthrough */
554  case 24:
555  _zip_buffer_set_offset(ef_buffer, 0);
556  if ((zde->uncomp_size != _zip_buffer_get_64(ef_buffer)) || (zde->comp_size != _zip_buffer_get_64(ef_buffer)) || (zde->offset != _zip_buffer_get_64(ef_buffer))) {
557  ok = false;
558  }
559  break;
560 
561  default:
562  ok = false;
563  }
564  if (!ok) {
566  _zip_buffer_free(ef_buffer);
567  if (!from_buffer) {
569  }
570  return -1;
571  }
572  }
573  _zip_buffer_free(ef_buffer);
574  }
575 
576  if (!_zip_buffer_ok(buffer)) {
578  if (!from_buffer) {
580  }
581  return -1;
582  }
583  if (!from_buffer) {
585  }
586 
587  /* zip_source_seek / zip_source_tell don't support values > ZIP_INT64_MAX */
588  if (zde->offset > ZIP_INT64_MAX) {
590  return -1;
591  }
592 
594  return -1;
595  }
596 
598 
599  return (zip_int64_t)size + (zip_int64_t)variable_size;
600 }
601 
602 
603 static zip_string_t *
605  zip_uint16_t ef_len;
606  zip_uint32_t ef_crc;
608 
609  const zip_uint8_t *ef = _zip_ef_get_by_id(de->extra_fields, &ef_len, id, 0, ZIP_EF_BOTH, NULL);
610 
611  if (ef == NULL || ef_len < 5 || ef[0] != 1) {
612  return str;
613  }
614 
615  if ((buffer = _zip_buffer_new((zip_uint8_t *)ef, ef_len)) == NULL) {
616  return str;
617  }
618 
620  ef_crc = _zip_buffer_get_32(buffer);
621 
622  if (_zip_string_crc32(str) == ef_crc) {
625 
626  if (ef_str != NULL) {
628  str = ef_str;
629  }
630  }
631 
633 
634  return str;
635 }
636 
637 
638 static bool
640  zip_uint16_t ef_len;
642  const zip_uint8_t *ef;
643  bool crc_valid;
644  zip_uint16_t enc_method;
645 
646 
647  if (de->comp_method != ZIP_CM_WINZIP_AES) {
648  return true;
649  }
650 
652 
653  if (ef == NULL || ef_len < 7) {
655  return false;
656  }
657 
658  if ((buffer = _zip_buffer_new((zip_uint8_t *)ef, ef_len)) == NULL) {
660  return false;
661  }
662 
663  /* version */
664 
665  crc_valid = true;
666  switch (_zip_buffer_get_16(buffer)) {
667  case 1:
668  break;
669 
670  case 2:
671  crc_valid = false;
672  /* TODO: When checking consistency, check that crc is 0. */
673  break;
674 
675  default:
678  return false;
679  }
680 
681  /* vendor */
682  if (memcmp(_zip_buffer_get(buffer, 2), "AE", 2) != 0) {
685  return false;
686  }
687 
688  /* mode */
689  switch (_zip_buffer_get_8(buffer)) {
690  case 1:
691  enc_method = ZIP_EM_AES_128;
692  break;
693  case 2:
694  enc_method = ZIP_EM_AES_192;
695  break;
696  case 3:
697  enc_method = ZIP_EM_AES_256;
698  break;
699  default:
702  return false;
703  }
704 
705  if (ef_len != 7) {
708  return false;
709  }
710 
711  de->crc_valid = crc_valid;
712  de->encryption_method = enc_method;
714 
716  return true;
717 }
718 
719 
723  bool local = (flags & ZIP_EF_LOCAL) != 0;
724  int i;
725  zip_uint8_t b[6];
727 
729 
730  if (zip_source_seek(src, local ? 26 : 28, SEEK_CUR) < 0) {
732  return -1;
733  }
734 
735  if ((buffer = _zip_buffer_new_from_source(src, local ? 4 : 6, b, error)) == NULL) {
736  return -1;
737  }
738 
739  for (i = 0; i < (local ? 2 : 3); i++) {
741  }
742 
743  if (!_zip_buffer_eof(buffer)) {
746  return -1;
747  }
748 
750  return size;
751 }
752 
753 
754 /* _zip_dirent_write
755  Writes zip directory entry.
756 
757  If flags & ZIP_EF_LOCAL, it writes a local header instead of a central
758  directory entry. If flags & ZIP_EF_FORCE_ZIP64, a ZIP64 extra field is written, even if not needed.
759 
760  Returns 0 if successful, 1 if successful and wrote ZIP64 extra field. On error, error is filled in and -1 is
761  returned.
762 */
763 
764 int
766  zip_uint16_t dostime, dosdate;
767  zip_encoding_type_t com_enc, name_enc;
769  zip_extra_field_t *ef64;
770  zip_uint32_t ef_total_size;
771  bool is_zip64;
772  bool is_really_zip64;
773  bool is_winzip_aes;
776 
777  ef = NULL;
778 
781 
782  if ((name_enc == ZIP_ENCODING_UTF8_KNOWN && com_enc == ZIP_ENCODING_ASCII) || (name_enc == ZIP_ENCODING_ASCII && com_enc == ZIP_ENCODING_UTF8_KNOWN) || (name_enc == ZIP_ENCODING_UTF8_KNOWN && com_enc == ZIP_ENCODING_UTF8_KNOWN))
784  else {
786  if (name_enc == ZIP_ENCODING_UTF8_KNOWN) {
788  if (ef == NULL)
789  return -1;
790  }
791  if ((flags & ZIP_FL_LOCAL) == 0 && com_enc == ZIP_ENCODING_UTF8_KNOWN) {
793  if (ef2 == NULL) {
794  _zip_ef_free(ef);
795  return -1;
796  }
797  ef2->next = ef;
798  ef = ef2;
799  }
800  }
801 
802  if (de->encryption_method == ZIP_EM_NONE) {
804  }
805  else {
807  }
808 
809  is_really_zip64 = _zip_dirent_needs_zip64(de, flags);
810  is_zip64 = (flags & (ZIP_FL_LOCAL | ZIP_FL_FORCE_ZIP64)) == (ZIP_FL_LOCAL | ZIP_FL_FORCE_ZIP64) || is_really_zip64;
812 
813  if (is_zip64) {
814  zip_uint8_t ef_zip64[EFZIP64SIZE];
815  zip_buffer_t *ef_buffer = _zip_buffer_new(ef_zip64, sizeof(ef_zip64));
816  if (ef_buffer == NULL) {
818  _zip_ef_free(ef);
819  return -1;
820  }
821 
822  if (flags & ZIP_FL_LOCAL) {
824  _zip_buffer_put_64(ef_buffer, de->uncomp_size);
825  _zip_buffer_put_64(ef_buffer, de->comp_size);
826  }
827  }
828  else {
830  if (de->uncomp_size >= ZIP_UINT32_MAX) {
831  _zip_buffer_put_64(ef_buffer, de->uncomp_size);
832  }
833  if (de->comp_size >= ZIP_UINT32_MAX) {
834  _zip_buffer_put_64(ef_buffer, de->comp_size);
835  }
836  if (de->offset >= ZIP_UINT32_MAX) {
837  _zip_buffer_put_64(ef_buffer, de->offset);
838  }
839  }
840  }
841 
842  if (!_zip_buffer_ok(ef_buffer)) {
844  _zip_buffer_free(ef_buffer);
845  _zip_ef_free(ef);
846  return -1;
847  }
848 
849  ef64 = _zip_ef_new(ZIP_EF_ZIP64, (zip_uint16_t)(_zip_buffer_offset(ef_buffer)), ef_zip64, ZIP_EF_BOTH);
850  _zip_buffer_free(ef_buffer);
851  ef64->next = ef;
852  ef = ef64;
853  }
854 
855  if (is_winzip_aes) {
857  zip_buffer_t *ef_buffer = _zip_buffer_new(data, sizeof(data));
858  zip_extra_field_t *ef_winzip;
859 
860  if (ef_buffer == NULL) {
862  _zip_ef_free(ef);
863  return -1;
864  }
865 
866  _zip_buffer_put_16(ef_buffer, 2);
867  _zip_buffer_put(ef_buffer, "AE", 2);
868  _zip_buffer_put_8(ef_buffer, (zip_uint8_t)(de->encryption_method & 0xff));
870 
871  if (!_zip_buffer_ok(ef_buffer)) {
873  _zip_buffer_free(ef_buffer);
874  _zip_ef_free(ef);
875  return -1;
876  }
877 
879  _zip_buffer_free(ef_buffer);
880  ef_winzip->next = ef;
881  ef = ef_winzip;
882  }
883 
884  if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) {
886  _zip_ef_free(ef);
887  return -1;
888  }
889 
891 
892  if ((flags & ZIP_FL_LOCAL) == 0) {
894  }
895  _zip_buffer_put_16(buffer, ZIP_MAX(is_really_zip64 ? 45 : 0, de->version_needed));
897  if (is_winzip_aes) {
899  }
900  else {
902  }
903 
904  _zip_u2d_time(de->last_mod, &dostime, &dosdate);
905  _zip_buffer_put_16(buffer, dostime);
906  _zip_buffer_put_16(buffer, dosdate);
907 
908  if (is_winzip_aes && de->uncomp_size < 20) {
910  }
911  else {
913  }
914 
915  if (((flags & ZIP_FL_LOCAL) == ZIP_FL_LOCAL) && ((de->comp_size >= ZIP_UINT32_MAX) || (de->uncomp_size >= ZIP_UINT32_MAX))) {
916  /* In local headers, if a ZIP64 EF is written, it MUST contain
917  * both compressed and uncompressed sizes (even if one of the
918  * two is smaller than 0xFFFFFFFF); on the other hand, those
919  * may only appear when the corresponding standard entry is
920  * 0xFFFFFFFF. (appnote.txt 4.5.3) */
923  }
924  else {
925  if (de->comp_size < ZIP_UINT32_MAX) {
927  }
928  else {
930  }
931  if (de->uncomp_size < ZIP_UINT32_MAX) {
933  }
934  else {
936  }
937  }
938 
940  /* TODO: check for overflow */
942  _zip_buffer_put_16(buffer, (zip_uint16_t)ef_total_size);
943 
944  if ((flags & ZIP_FL_LOCAL) == 0) {
949  if (de->offset < ZIP_UINT32_MAX)
951  else
953  }
954 
955  if (!_zip_buffer_ok(buffer)) {
958  _zip_ef_free(ef);
959  return -1;
960  }
961 
962  if (_zip_write(za, buf, _zip_buffer_offset(buffer)) < 0) {
964  _zip_ef_free(ef);
965  return -1;
966  }
967 
969 
970  if (de->filename) {
971  if (_zip_string_write(za, de->filename) < 0) {
972  _zip_ef_free(ef);
973  return -1;
974  }
975  }
976 
977  if (ef) {
978  if (_zip_ef_write(za, ef, ZIP_EF_BOTH) < 0) {
979  _zip_ef_free(ef);
980  return -1;
981  }
982  }
983  _zip_ef_free(ef);
984  if (de->extra_fields) {
985  if (_zip_ef_write(za, de->extra_fields, flags) < 0) {
986  return -1;
987  }
988  }
989 
990  if ((flags & ZIP_FL_LOCAL) == 0) {
991  if (de->comment) {
992  if (_zip_string_write(za, de->comment) < 0) {
993  return -1;
994  }
995  }
996  }
997 
998 
999  return is_zip64;
1000 }
1001 
1002 
1003 time_t
1005  struct tm tm;
1006 
1007  memset(&tm, 0, sizeof(tm));
1008 
1009  /* let mktime decide if DST is in effect */
1010  tm.tm_isdst = -1;
1011 
1012  tm.tm_year = ((ddate >> 9) & 127) + 1980 - 1900;
1013  tm.tm_mon = ((ddate >> 5) & 15) - 1;
1014  tm.tm_mday = ddate & 31;
1015 
1016  tm.tm_hour = (dtime >> 11) & 31;
1017  tm.tm_min = (dtime >> 5) & 63;
1018  tm.tm_sec = (dtime << 1) & 62;
1019 
1020  return mktime(&tm);
1021 }
1022 
1023 
1024 static zip_extra_field_t *
1026  const zip_uint8_t *raw;
1027  zip_uint32_t len;
1030 
1031  if ((raw = _zip_string_get(str, &len, ZIP_FL_ENC_RAW, NULL)) == NULL) {
1032  /* error already set */
1033  return NULL;
1034  }
1035 
1036  if (len + 5 > ZIP_UINT16_MAX) {
1037  zip_error_set(error, ZIP_ER_INVAL, 0); /* TODO: better error code? */
1038  return NULL;
1039  }
1040 
1041  if ((buffer = _zip_buffer_new(NULL, len + 5)) == NULL) {
1043  return NULL;
1044  }
1045 
1048  _zip_buffer_put(buffer, raw, len);
1049 
1050  if (!_zip_buffer_ok(buffer)) {
1053  return NULL;
1054  }
1055 
1058 
1059  return ef;
1060 }
1061 
1062 
1063 zip_dirent_t *
1065  if (error == NULL)
1066  error = &za->error;
1067 
1068  if (idx >= za->nentry) {
1070  return NULL;
1071  }
1072 
1073  if ((flags & ZIP_FL_UNCHANGED) || za->entry[idx].changes == NULL) {
1074  if (za->entry[idx].orig == NULL) {
1076  return NULL;
1077  }
1078  if (za->entry[idx].deleted && (flags & ZIP_FL_UNCHANGED) == 0) {
1080  return NULL;
1081  }
1082  return za->entry[idx].orig;
1083  }
1084  else
1085  return za->entry[idx].changes;
1086 }
1087 
1088 
1089 void
1091  struct tm *tpm;
1092 
1093 #ifdef HAVE_LOCALTIME_R
1094  struct tm tm;
1095  tpm = localtime_r(&intime, &tm);
1096 #else
1097  tpm = localtime(&intime);
1098 #endif
1099  if (tpm == NULL) {
1100  /* if localtime() fails, return an arbitrary date (1980-01-01 00:00:00) */
1101  *ddate = (1 << 5) + 1;
1102  *dtime = 0;
1103  return;
1104  }
1105  if (tpm->tm_year < 80) {
1106  tpm->tm_year = 80;
1107  }
1108 
1109  *ddate = (zip_uint16_t)(((tpm->tm_year + 1900 - 1980) << 9) + ((tpm->tm_mon + 1) << 5) + tpm->tm_mday);
1110  *dtime = (zip_uint16_t)(((tpm->tm_hour) << 11) + ((tpm->tm_min) << 5) + ((tpm->tm_sec) >> 1));
1111 
1112  return;
1113 }
1114 
1115 
1116 void
1117 _zip_dirent_apply_attributes(zip_dirent_t *de, zip_file_attributes_t *attributes, bool force_zip64, zip_uint32_t changed) {
1119 
1122  de->bitflags = (de->bitflags & ~mask) | (attributes->general_purpose_bit_flags & mask);
1123  }
1124  if (attributes->valid & ZIP_FILE_ATTRIBUTES_ASCII) {
1125  de->int_attrib = (de->int_attrib & ~0x1) | (attributes->ascii ? 1 : 0);
1126  }
1127  /* manually set attributes are preferred over attributes provided by source */
1128  if ((changed & ZIP_DIRENT_ATTRIBUTES) == 0 && (attributes->valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES)) {
1129  de->ext_attrib = attributes->external_file_attributes;
1130  }
1131 
1132  if (de->comp_method == ZIP_CM_LZMA) {
1133  de->version_needed = 63;
1134  }
1136  de->version_needed = 51;
1137  }
1138  else if (de->comp_method == ZIP_CM_BZIP2) {
1139  de->version_needed = 46;
1140  }
1141  else if (force_zip64 || _zip_dirent_needs_zip64(de, 0)) {
1142  de->version_needed = 45;
1143  }
1144  else if (de->comp_method == ZIP_CM_DEFLATE || de->encryption_method == ZIP_EM_TRAD_PKWARE) {
1145  de->version_needed = 20;
1146  }
1147  else if ((length = _zip_string_length(de->filename)) > 0 && de->filename->raw[length - 1] == '/') {
1148  de->version_needed = 20;
1149  }
1150  else {
1151  de->version_needed = 10;
1152  }
1153 
1154  if (attributes->valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED) {
1155  de->version_needed = ZIP_MAX(de->version_needed, attributes->version_needed);
1156  }
1157 
1158  de->version_madeby = 63 | (de->version_madeby & 0xff00);
1159  if ((changed & ZIP_DIRENT_ATTRIBUTES) == 0 && (attributes->valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM)) {
1160  de->version_madeby = (de->version_madeby & 0xff) | (zip_uint16_t)(attributes->host_system << 8);
1161  }
1162 }
size_t len
Definition: 6502dis.c:15
#define ef(frag,...)
#define mask()
lzma_index ** i
Definition: index.h:629
lzma_index * src
Definition: index.h:567
static csh cd
Definition: asm_mips_cs.c:10
#define local
Definition: blast.c:36
struct buffer buffer
#define NULL
Definition: cris-opc.c:27
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
#define ZIP_ER_INTERNAL
Definition: zip.h:125
#define ZIP_FILE_ATTRIBUTES_ASCII
Definition: zip.h:330
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
#define ZIP_ER_SEEK
Definition: zip.h:109
#define ZIP_ER_MEMORY
Definition: zip.h:119
#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM
Definition: zip.h:329
#define ZIP_EM_TRAD_PKWARE
Definition: zip.h:178
#define ZIP_EM_AES_256
Definition: zip.h:192
#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES
Definition: zip.h:332
ZIP_EXTERN int zip_source_seek(zip_source_t *_Nonnull, zip_int64_t, int)
#define ZIP_ER_DELETED
Definition: zip.h:128
#define ZIP_FL_LOCAL
Definition: zip.h:85
#define ZIP_CM_BZIP2
Definition: zip.h:161
#define ZIP_ER_ENCRNOTSUPP
Definition: zip.h:129
#define ZIP_EM_UNKNOWN
Definition: zip.h:193
#define ZIP_CM_LZMA
Definition: zip.h:163
#define ZIP_EM_AES_192
Definition: zip.h:191
#define ZIP_EM_NONE
Definition: zip.h:177
ZIP_EXTERN zip_int64_t zip_source_tell_write(zip_source_t *_Nonnull)
#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS
Definition: zip.h:333
#define ZIP_CM_DEFAULT
Definition: zip.h:148
#define ZIP_FL_CENTRAL
Definition: zip.h:86
#define ZIP_ER_INVAL
Definition: zip.h:123
#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED
Definition: zip.h:331
ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull)
Definition: zip_error.c:46
zip_uint32_t zip_flags_t
Definition: zip.h:347
#define ZIP_FL_ENC_RAW
Definition: zip.h:83
#define ZIP_ER_EOF
Definition: zip.h:122
#define ZIP_FL_ENC_UTF_8
Definition: zip.h:88
#define ZIP_ER_NOZIP
Definition: zip.h:124
#define ZIP_CM_DEFLATE
Definition: zip.h:157
#define ZIP_FL_UNCHANGED
Definition: zip.h:79
#define ZIP_ER_INCONS
Definition: zip.h:126
#define ZIP_OPSYS_DEFAULT
Definition: zip.h:216
#define ZIP_EM_AES_128
Definition: zip.h:190
void * realloc(void *ptr, size_t size)
Definition: malloc.c:144
void * malloc(size_t size)
Definition: malloc.c:123
@ ok
Definition: lz4.c:1706
int idx
Definition: setup.py:197
int off
Definition: pal.c:13
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
#define EFBIG
Definition: sftypes.h:137
int time_t
Definition: sftypes.h:66
#define b(i)
Definition: sha256.c:42
#define SIZE_MAX
Definition: buffer.h:15
Definition: zipcmp.c:69
Definition: zipcmp.c:77
zip_uint32_t disk_number
Definition: zipint.h:344
zip_uint16_t bitflags
Definition: zipint.h:335
bool local_extra_fields_read
Definition: zipint.h:328
time_t last_mod
Definition: zipint.h:337
zip_uint64_t uncomp_size
Definition: zipint.h:340
zip_uint32_t crc
Definition: zipint.h:338
zip_uint16_t int_attrib
Definition: zipint.h:345
zip_uint64_t offset
Definition: zipint.h:347
char * password
Definition: zipint.h:351
bool cloned
Definition: zipint.h:329
zip_int32_t comp_method
Definition: zipint.h:336
zip_uint64_t comp_size
Definition: zipint.h:339
zip_uint16_t version_needed
Definition: zipint.h:334
zip_uint32_t changed
Definition: zipint.h:327
zip_uint32_t ext_attrib
Definition: zipint.h:346
zip_extra_field_t * extra_fields
Definition: zipint.h:342
zip_uint16_t encryption_method
Definition: zipint.h:350
bool crc_valid
Definition: zipint.h:331
zip_uint16_t version_madeby
Definition: zipint.h:333
zip_string_t * comment
Definition: zipint.h:343
zip_string_t * filename
Definition: zipint.h:341
zip_uint16_t compression_level
Definition: zipint.h:349
Definition: zipint.h:408
zip_dirent_t * orig
Definition: zipint.h:409
zip_dirent_t * changes
Definition: zipint.h:410
bool deleted
Definition: zipint.h:412
Definition: zip.h:284
zip_extra_field_t * next
Definition: zipint.h:368
zip_uint8_t host_system
Definition: zip.h:321
zip_uint16_t general_purpose_bit_mask
Definition: zip.h:326
zip_uint8_t ascii
Definition: zip.h:322
zip_uint16_t general_purpose_bit_flags
Definition: zip.h:325
zip_uint8_t version_needed
Definition: zip.h:323
zip_uint32_t external_file_attributes
Definition: zip.h:324
zip_uint64_t valid
Definition: zip.h:319
zip_uint64_t idx
Definition: zipint.h:458
zip_uint8_t * raw
Definition: zipint.h:419
zip_uint16_t length
Definition: zipint.h:420
Definition: zipint.h:278
zip_error_t error
Definition: zipint.h:281
zip_string_t * comment_changes
Definition: zipint.h:289
zip_source_t * src
Definition: zipint.h:279
zip_entry_t * entry
Definition: zipint.h:294
zip_uint64_t nentry
Definition: zipint.h:292
zip_string_t * comment_orig
Definition: zipint.h:288
bool comment_changed
Definition: zipint.h:290
void error(const char *msg)
Definition: untgz.c:593
#define SEEK_CUR
Definition: zip.c:80
int _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i)
Definition: zip_buffer.c:283
zip_uint8_t * _zip_buffer_data(zip_buffer_t *buffer)
Definition: zip_buffer.c:40
zip_uint32_t _zip_buffer_get_32(zip_buffer_t *buffer)
Definition: zip_buffer.c:92
zip_uint64_t _zip_buffer_left(zip_buffer_t *buffer)
Definition: zip_buffer.c:128
int _zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i)
Definition: zip_buffer.c:230
zip_buffer_t * _zip_buffer_new(zip_uint8_t *data, zip_uint64_t size)
Definition: zip_buffer.c:146
void _zip_buffer_free(zip_buffer_t *buffer)
Definition: zip_buffer.c:46
zip_buffer_t * _zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error)
Definition: zip_buffer.c:174
bool _zip_buffer_ok(zip_buffer_t *buffer)
Definition: zip_buffer.c:198
zip_uint16_t _zip_buffer_get_16(zip_buffer_t *buffer)
Definition: zip_buffer.c:80
int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length)
Definition: zip_buffer.c:311
int _zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i)
Definition: zip_buffer.c:262
bool _zip_buffer_eof(zip_buffer_t *buffer)
Definition: zip_buffer.c:60
zip_uint64_t _zip_buffer_get_64(zip_buffer_t *buffer)
Definition: zip_buffer.c:104
int _zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i)
Definition: zip_buffer.c:245
zip_uint8_t _zip_buffer_get_8(zip_buffer_t *buffer)
Definition: zip_buffer.c:116
zip_uint64_t _zip_buffer_offset(zip_buffer_t *buffer)
Definition: zip_buffer.c:192
int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset)
Definition: zip_buffer.c:297
int _zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length)
Definition: zip_buffer.c:217
zip_uint8_t * _zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length)
Definition: zip_buffer.c:66
zip_dirent_t * _zip_dirent_new(void)
Definition: zip_dirent.c:305
zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors)
Definition: zip_dirent.c:121
zip_dirent_t * _zip_dirent_clone(const zip_dirent_t *sde)
Definition: zip_dirent.c:215
void _zip_cdir_free(zip_cdir_t *cd)
Definition: zip_dirent.c:49
void _zip_dirent_apply_attributes(zip_dirent_t *de, zip_file_attributes_t *attributes, bool force_zip64, zip_uint32_t changed)
Definition: zip_dirent.c:1117
void _zip_u2d_time(time_t intime, zip_uint16_t *dtime, zip_uint16_t *ddate)
Definition: zip_dirent.c:1090
static bool _zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error)
Definition: zip_dirent.c:639
int _zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags)
Definition: zip_dirent.c:765
zip_dirent_t * _zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error)
Definition: zip_dirent.c:1064
static zip_extra_field_t * _zip_ef_utf8(zip_uint16_t, zip_string_t *, zip_error_t *)
Definition: zip_dirent.c:1025
zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t flags, zip_error_t *error)
Definition: zip_dirent.c:721
void _zip_dirent_init(zip_dirent_t *de)
Definition: zip_dirent.c:268
void _zip_dirent_finalize(zip_dirent_t *zde)
Definition: zip_dirent.c:234
zip_cdir_t * _zip_cdir_new(zip_uint64_t nentry, zip_error_t *error)
Definition: zip_dirent.c:64
zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error)
Definition: zip_dirent.c:327
void _zip_dirent_free(zip_dirent_t *zde)
Definition: zip_dirent.c:258
bool _zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error)
Definition: zip_dirent.c:88
static zip_string_t * _zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str)
Definition: zip_dirent.c:604
bool _zip_dirent_needs_zip64(const zip_dirent_t *de, zip_flags_t flags)
Definition: zip_dirent.c:296
time_t _zip_d2u_time(zip_uint16_t dtime, zip_uint16_t ddate)
Definition: zip_dirent.c:1004
void _zip_entry_init(zip_entry_t *e)
Definition: zip_entry.c:46
void _zip_entry_finalize(zip_entry_t *e)
Definition: zip_entry.c:38
void _zip_error_set_from_source(zip_error_t *err, zip_source_t *src)
Definition: zip_error.c:135
bool _zip_ef_parse(const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags, zip_extra_field_t **ef_head_p, zip_error_t *error)
zip_uint16_t _zip_ef_size(const zip_extra_field_t *ef, zip_flags_t flags)
zip_extra_field_t * _zip_ef_remove_internal(zip_extra_field_t *ef)
zip_extra_field_t * _zip_ef_new(zip_uint16_t id, zip_uint16_t size, const zip_uint8_t *data, zip_flags_t flags)
int _zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags)
const zip_uint8_t * _zip_ef_get_by_id(const zip_extra_field_t *ef, zip_uint16_t *lenp, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags, zip_error_t *error)
void _zip_ef_free(zip_extra_field_t *ef)
zip_uint8_t * _zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error)
Definition: zip_io_util.c:63
int _zip_write(zip_t *za, const void *data, zip_uint64_t length)
Definition: zip_io_util.c:121
zip_string_t * _zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t len, bool nulp, zip_error_t *error)
Definition: zip_io_util.c:107
zip_uint32_t _zip_string_crc32(const zip_string_t *s)
Definition: zip_string.c:42
zip_string_t * _zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_error_t *error)
Definition: zip_string.c:121
void _zip_string_free(zip_string_t *s)
Definition: zip_string.c:69
const zip_uint8_t * _zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip_error_t *error)
Definition: zip_string.c:80
int _zip_string_write(zip_t *za, const zip_string_t *s)
Definition: zip_string.c:173
zip_uint16_t _zip_string_length(const zip_string_t *s)
Definition: zip_string.c:112
zip_encoding_type_t _zip_guess_encoding(zip_string_t *str, zip_encoding_type_t expected_encoding)
Definition: zip_utf-8.c:100
#define ZIP_UINT16_MAX
Definition: zipconf.h:47
uint64_t zip_uint64_t
Definition: zipconf.h:39
#define ZIP_UINT32_MAX
Definition: zipconf.h:51
uint32_t zip_uint32_t
Definition: zipconf.h:37
uint8_t zip_uint8_t
Definition: zipconf.h:33
int32_t zip_int32_t
Definition: zipconf.h:36
uint16_t zip_uint16_t
Definition: zipconf.h:35
#define ZIP_INT64_MAX
Definition: zipconf.h:54
int64_t zip_int64_t
Definition: zipconf.h:38
#define ZIP_DIRENT_ATTRIBUTES
Definition: zipint.h:320
#define LENTRYSIZE
Definition: zipint.h:58
#define ZIP_DIRENT_PASSWORD
Definition: zipint.h:323
#define ZIP_ER_DETAIL_INVALID_UTF8_IN_COMMENT
Definition: zipint.h:227
#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK
Definition: zipint.h:97
#define ZIP_EF_BOTH
Definition: zipint.h:245
#define ZIP_EF_CENTRAL
Definition: zipint.h:244
#define CDENTRYSIZE
Definition: zipint.h:57
#define EOCD_MAGIC
Definition: zipint.h:53
#define CENTRAL_MAGIC
Definition: zipint.h:51
#define ZIP_EF_LOCAL
Definition: zipint.h:243
#define ZIP_EF_WINZIP_AES
Definition: zipint.h:87
#define ZIP_FL_FORCE_ZIP64
Definition: zipint.h:247
#define EOCD64LEN
Definition: zipint.h:63
#define ZIP_MAX(a, b)
Definition: zipint.h:472
#define ZIP_DIRENT_EXTRA_FIELD
Definition: zipint.h:319
#define ZIP_ER_DETAIL_INVALID_ZIP64_EF
Definition: zipint.h:228
#define EOCDLEN
Definition: zipint.h:61
#define ZIP_EF_UTF_8_NAME
Definition: zipint.h:86
#define ZIP_DIRENT_FILENAME
Definition: zipint.h:317
#define EFZIP64SIZE
Definition: zipint.h:66
#define ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW
Definition: zipint.h:225
#define ZIP_GPBF_ENCODING_UTF_8
Definition: zipint.h:239
enum zip_encoding_type zip_encoding_type_t
Definition: zipint.h:262
#define EOCD64_MAGIC
Definition: zipint.h:56
#define EOCD64LOCLEN
Definition: zipint.h:62
#define ZIP_GPBF_STRONG_ENCRYPTION
Definition: zipint.h:238
#define EF_WINZIP_AES_SIZE
Definition: zipint.h:67
#define ZIP_EXT_ATTRIB_DEFAULT
Definition: zipint.h:93
#define EOCD64LOC_MAGIC
Definition: zipint.h:55
#define _zip_crypto_clear(b, l)
Definition: zipint.h:489
#define ZIP_EF_ZIP64
Definition: zipint.h:88
#define ZIP_EF_UTF_8_COMMENT
Definition: zipint.h:85
#define ZIP_ER_DETAIL_INVALID_UTF8_IN_FILENAME
Definition: zipint.h:226
#define LOCAL_MAGIC
Definition: zipint.h:52
#define ZIP_DIRENT_COMMENT
Definition: zipint.h:318
#define ZIP_ER_DETAIL_INVALID_WINZIPAES_EF
Definition: zipint.h:229
#define ZIP_CM_WINZIP_AES
Definition: zipint.h:73
#define ZIP_GPBF_ENCRYPTED
Definition: zipint.h:236
@ ZIP_ENCODING_ERROR
Definition: zipint.h:259
@ ZIP_ENCODING_UTF8_KNOWN
Definition: zipint.h:256
@ ZIP_ENCODING_UNKNOWN
Definition: zipint.h:254
@ ZIP_ENCODING_ASCII
Definition: zipint.h:255
zip_t * za
Definition: ziptool.c:79