diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:27:26 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:27:26 -0700 |
commit | 7751bd4c715ea8478113e34b49b5a794a4642e8e (patch) | |
tree | 537ba82b3780f933c2f17028febd6fe3a2332190 /contrib/minizip/unzip.c | |
parent | e0ff940e1adb68d3575705ebf1546d9f07ad3b4a (diff) | |
download | zlib-1.2.3.9.tar.gz zlib-1.2.3.9.tar.bz2 zlib-1.2.3.9.zip |
zlib 1.2.3.9v1.2.3.9
Diffstat (limited to 'contrib/minizip/unzip.c')
-rw-r--r-- | contrib/minizip/unzip.c | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index 6a4d104..7617f41 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
@@ -1,16 +1,16 @@ | |||
1 | /* unzip.c -- IO for uncompress .zip files using zlib | 1 | /* unzip.c -- IO for uncompress .zip files using zlib |
2 | Version 1.1, January 7th, 2010 | 2 | Version 1.1, February 14h, 2010 |
3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) | 3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) |
4 | 4 | ||
5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) | 5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) |
6 | 6 | ||
7 | Modifications of Unzip for Zip64 | 7 | Modifications of Unzip for Zip64 |
8 | Copyright (C) 2007-2008 Even Rouault | 8 | Copyright (C) 2007-2008 Even Rouault |
9 | 9 | ||
10 | Modifications for Zip64 support on both zip and unzip | 10 | Modifications for Zip64 support on both zip and unzip |
11 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | 11 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
12 | 12 | ||
13 | For more info read MiniZip_info.txt | 13 | For more info read MiniZip_info.txt |
14 | 14 | ||
15 | 15 | ||
16 | ------------------------------------------------------------------------------------ | 16 | ------------------------------------------------------------------------------------ |
@@ -25,39 +25,41 @@ | |||
25 | If, for some reason, all these files are missing, the Info-ZIP license | 25 | If, for some reason, all these files are missing, the Info-ZIP license |
26 | also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html | 26 | also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html |
27 | 27 | ||
28 | crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] | 28 | crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] |
29 | 29 | ||
30 | The encryption/decryption parts of this source code (as opposed to the | 30 | The encryption/decryption parts of this source code (as opposed to the |
31 | non-echoing password parts) were originally written in Europe. The | 31 | non-echoing password parts) were originally written in Europe. The |
32 | whole source package can be freely distributed, including from the USA. | 32 | whole source package can be freely distributed, including from the USA. |
33 | (Prior to January 2000, re-export from the US was a violation of US law.) | 33 | (Prior to January 2000, re-export from the US was a violation of US law.) |
34 | 34 | ||
35 | This encryption code is a direct transcription of the algorithm from | 35 | This encryption code is a direct transcription of the algorithm from |
36 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This | 36 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This |
37 | file (appnote.txt) is distributed with the PKZIP program (even in the | 37 | file (appnote.txt) is distributed with the PKZIP program (even in the |
38 | version without encryption capabilities). | 38 | version without encryption capabilities). |
39 | 39 | ||
40 | ------------------------------------------------------------------------------------ | 40 | ------------------------------------------------------------------------------------ |
41 | 41 | ||
42 | Changes in unzip64.c | 42 | Changes in unzip.c |
43 | 43 | ||
44 | 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos | 44 | 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos |
45 | 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* | 45 | 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* |
46 | 2007-2008 - Even Rouault - Remove old C style function prototypes | 46 | 2007-2008 - Even Rouault - Remove old C style function prototypes |
47 | 2007-2008 - Even Rouault - Add unzip support for ZIP64 | 47 | 2007-2008 - Even Rouault - Add unzip support for ZIP64 |
48 | 48 | ||
49 | Copyright (C) 2007-2008 Even Rouault | 49 | Copyright (C) 2007-2008 Even Rouault |
50 | 50 | ||
51 | 51 | ||
52 | Okt-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). | 52 | Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). |
53 | Okt-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G | 53 | Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G |
54 | should only read the compressed/uncompressed size from the Zip64 format if | 54 | should only read the compressed/uncompressed size from the Zip64 format if |
55 | the size from normal header was 0xFFFFFFFF | 55 | the size from normal header was 0xFFFFFFFF |
56 | Okt-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant | 56 | Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant |
57 | Okt-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) | 57 | Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) |
58 | Patch created by Daniel Borca | 58 | Patch created by Daniel Borca |
59 | 59 | ||
60 | Copyright (C) 2009 Mathias Svensson | 60 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
61 | |||
62 | Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson | ||
61 | 63 | ||
62 | */ | 64 | */ |
63 | 65 | ||
@@ -67,7 +69,7 @@ | |||
67 | #include <string.h> | 69 | #include <string.h> |
68 | 70 | ||
69 | #ifndef NOUNCRYPT | 71 | #ifndef NOUNCRYPT |
70 | #define NOUNCRYPT | 72 | #define NOUNCRYPT |
71 | #endif | 73 | #endif |
72 | 74 | ||
73 | #include "zlib.h" | 75 | #include "zlib.h" |
@@ -482,7 +484,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib | |||
482 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ | 484 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
483 | ZPOS64_T uPosFound=0; | 485 | ZPOS64_T uPosFound=0; |
484 | uLong uL; | 486 | uLong uL; |
485 | ZPOS64_T relativeOffset; | 487 | ZPOS64_T relativeOffset; |
486 | 488 | ||
487 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) | 489 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
488 | return 0; | 490 | return 0; |
@@ -957,7 +959,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, | |||
957 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) | 959 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) |
958 | err=UNZ_ERRNO; | 960 | err=UNZ_ERRNO; |
959 | 961 | ||
960 | // relative offset of local header | 962 | // relative offset of local header |
961 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) | 963 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
962 | err=UNZ_ERRNO; | 964 | err=UNZ_ERRNO; |
963 | file_info_internal.offset_curfile = uL; | 965 | file_info_internal.offset_curfile = uL; |
@@ -1009,7 +1011,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, | |||
1009 | 1011 | ||
1010 | if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) | 1012 | if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) |
1011 | { | 1013 | { |
1012 | uLong acc = 0; | 1014 | uLong acc = 0; |
1013 | 1015 | ||
1014 | // since lSeek now points to after the extra field we need to move back | 1016 | // since lSeek now points to after the extra field we need to move back |
1015 | lSeek -= file_info.size_file_extra; | 1017 | lSeek -= file_info.size_file_extra; |
@@ -1025,7 +1027,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, | |||
1025 | while(acc < file_info.size_file_extra) | 1027 | while(acc < file_info.size_file_extra) |
1026 | { | 1028 | { |
1027 | uLong headerId; | 1029 | uLong headerId; |
1028 | uLong dataSize; | 1030 | uLong dataSize; |
1029 | 1031 | ||
1030 | if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) | 1032 | if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) |
1031 | err=UNZ_ERRNO; | 1033 | err=UNZ_ERRNO; |
@@ -1036,33 +1038,33 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, | |||
1036 | /* ZIP64 extra fields */ | 1038 | /* ZIP64 extra fields */ |
1037 | if (headerId == 0x0001) | 1039 | if (headerId == 0x0001) |
1038 | { | 1040 | { |
1039 | uLong uL; | 1041 | uLong uL; |
1040 | 1042 | ||
1041 | if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1) | 1043 | if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1) |
1042 | { | 1044 | { |
1043 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) | 1045 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) |
1044 | err=UNZ_ERRNO; | 1046 | err=UNZ_ERRNO; |
1045 | } | 1047 | } |
1046 | 1048 | ||
1047 | if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1) | 1049 | if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1) |
1048 | { | 1050 | { |
1049 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) | 1051 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) |
1050 | err=UNZ_ERRNO; | 1052 | err=UNZ_ERRNO; |
1051 | } | 1053 | } |
1052 | 1054 | ||
1053 | if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1) | 1055 | if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1) |
1054 | { | 1056 | { |
1055 | /* Relative Header offset */ | 1057 | /* Relative Header offset */ |
1056 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) | 1058 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) |
1057 | err=UNZ_ERRNO; | 1059 | err=UNZ_ERRNO; |
1058 | } | 1060 | } |
1059 | 1061 | ||
1060 | if(file_info.disk_num_start == (unsigned long)-1) | 1062 | if(file_info.disk_num_start == (unsigned long)-1) |
1061 | { | 1063 | { |
1062 | /* Disk Start Number */ | 1064 | /* Disk Start Number */ |
1063 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) | 1065 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
1064 | err=UNZ_ERRNO; | 1066 | err=UNZ_ERRNO; |
1065 | } | 1067 | } |
1066 | 1068 | ||
1067 | } | 1069 | } |
1068 | else | 1070 | else |
@@ -1608,7 +1610,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, | |||
1608 | pfile_in_zip_read_info->stream.avail_in = (uInt)0; | 1610 | pfile_in_zip_read_info->stream.avail_in = (uInt)0; |
1609 | 1611 | ||
1610 | s->pfile_in_zip_read = pfile_in_zip_read_info; | 1612 | s->pfile_in_zip_read = pfile_in_zip_read_info; |
1611 | s->encrypted = 0; | 1613 | s->encrypted = 0; |
1612 | 1614 | ||
1613 | # ifndef NOUNCRYPT | 1615 | # ifndef NOUNCRYPT |
1614 | if (password != NULL) | 1616 | if (password != NULL) |
@@ -2051,7 +2053,7 @@ extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uS | |||
2051 | unz64_s* s; | 2053 | unz64_s* s; |
2052 | uLong uReadThis ; | 2054 | uLong uReadThis ; |
2053 | if (file==NULL) | 2055 | if (file==NULL) |
2054 | return (uLong)UNZ_PARAMERROR; | 2056 | return (int)UNZ_PARAMERROR; |
2055 | s=(unz64_s*)file; | 2057 | s=(unz64_s*)file; |
2056 | 2058 | ||
2057 | uReadThis = uSizeBuf; | 2059 | uReadThis = uSizeBuf; |