Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: third_party/zlib/contrib/minizip/zip.c

Issue 2079313002: Revert of Update Zlib to version 1.2.8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/zlib/contrib/minizip/unzip.c ('k') | third_party/zlib/crc32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* zip.c -- IO on .zip files using zlib 1 /* zip.c -- IO on .zip files using zlib
2 Version 1.1, February 14h, 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 for Zip64 support 7 Modifications for Zip64 support
8 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 8 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
9 9
10 For more info read MiniZip_info.txt 10 For more info read MiniZip_info.txt
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ 150 Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
151 uLong dosDate; 151 uLong dosDate;
152 uLong crc32; 152 uLong crc32;
153 int encrypt; 153 int encrypt;
154 int zip64; /* Add ZIP64 extened information in the extra fiel d */ 154 int zip64; /* Add ZIP64 extened information in the extra fiel d */
155 ZPOS64_T pos_zip64extrainfo; 155 ZPOS64_T pos_zip64extrainfo;
156 ZPOS64_T totalCompressedData; 156 ZPOS64_T totalCompressedData;
157 ZPOS64_T totalUncompressedData; 157 ZPOS64_T totalUncompressedData;
158 #ifndef NOCRYPT 158 #ifndef NOCRYPT
159 unsigned long keys[3]; /* keys defining the pseudo-random sequence */ 159 unsigned long keys[3]; /* keys defining the pseudo-random sequence */
160 const z_crc_t* pcrc_32_tab; 160 const unsigned long* pcrc_32_tab;
161 int crypt_header_size; 161 int crypt_header_size;
162 #endif 162 #endif
163 } curfile64_info; 163 } curfile64_info;
164 164
165 typedef struct 165 typedef struct
166 { 166 {
167 zlib_filefunc64_32_def z_filefunc; 167 zlib_filefunc64_32_def z_filefunc;
168 voidpf filestream; /* io structore of the zipfile */ 168 voidpf filestream; /* io structore of the zipfile */
169 linkedlist_data central_dir;/* datablock with central dir in construction*/ 169 linkedlist_data central_dir;/* datablock with central dir in construction*/
170 int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ 170 int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 const char* password, uLong crcForCrypt ing, 1060 const char* password, uLong crcForCrypt ing,
1061 uLong versionMadeBy, uLong flagBase, in t zip64) 1061 uLong versionMadeBy, uLong flagBase, in t zip64)
1062 { 1062 {
1063 zip64_internal* zi; 1063 zip64_internal* zi;
1064 uInt size_filename; 1064 uInt size_filename;
1065 uInt size_comment; 1065 uInt size_comment;
1066 uInt i; 1066 uInt i;
1067 int err = ZIP_OK; 1067 int err = ZIP_OK;
1068 1068
1069 # ifdef NOCRYPT 1069 # ifdef NOCRYPT
1070 (crcForCrypting);
1071 if (password != NULL) 1070 if (password != NULL)
1072 return ZIP_PARAMERROR; 1071 return ZIP_PARAMERROR;
1073 # endif 1072 # endif
1074 1073
1075 if (file == NULL) 1074 if (file == NULL)
1076 return ZIP_PARAMERROR; 1075 return ZIP_PARAMERROR;
1077 1076
1078 #ifdef HAVE_BZIP2 1077 #ifdef HAVE_BZIP2
1079 if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED)) 1078 if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED))
1080 return ZIP_PARAMERROR; 1079 return ZIP_PARAMERROR;
(...skipping 27 matching lines...) Expand all
1108 { 1107 {
1109 if (zipfi->dosDate != 0) 1108 if (zipfi->dosDate != 0)
1110 zi->ci.dosDate = zipfi->dosDate; 1109 zi->ci.dosDate = zipfi->dosDate;
1111 else 1110 else
1112 zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date); 1111 zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date);
1113 } 1112 }
1114 1113
1115 zi->ci.flag = flagBase; 1114 zi->ci.flag = flagBase;
1116 if ((level==8) || (level==9)) 1115 if ((level==8) || (level==9))
1117 zi->ci.flag |= 2; 1116 zi->ci.flag |= 2;
1118 if (level==2) 1117 if ((level==2))
1119 zi->ci.flag |= 4; 1118 zi->ci.flag |= 4;
1120 if (level==1) 1119 if ((level==1))
1121 zi->ci.flag |= 6; 1120 zi->ci.flag |= 6;
1122 if (password != NULL) 1121 if (password != NULL)
1123 zi->ci.flag |= 1; 1122 zi->ci.flag |= 1;
1124 1123
1125 zi->ci.crc32 = 0; 1124 zi->ci.crc32 = 0;
1126 zi->ci.method = method; 1125 zi->ci.method = method;
1127 zi->ci.encrypt = 0; 1126 zi->ci.encrypt = 0;
1128 zi->ci.stream_initialised = 0; 1127 zi->ci.stream_initialised = 0;
1129 zi->ci.pos_in_buffered_data = 0; 1128 zi->ci.pos_in_buffered_data = 0;
1130 zi->ci.raw = raw; 1129 zi->ci.raw = raw;
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 // Update the LocalFileHeader with the new values. 1703 // Update the LocalFileHeader with the new values.
1705 1704
1706 ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); 1705 ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
1707 1706
1708 if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14, ZLIB_FILEFUNC_SEEK_SET)!=0) 1707 if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14, ZLIB_FILEFUNC_SEEK_SET)!=0)
1709 err = ZIP_ERRNO; 1708 err = ZIP_ERRNO;
1710 1709
1711 if (err==ZIP_OK) 1710 if (err==ZIP_OK)
1712 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); / * crc 32, unknown */ 1711 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); / * crc 32, unknown */
1713 1712
1714 if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff ) 1713 if(uncompressed_size >= 0xffffffff)
1715 { 1714 {
1716 if(zi->ci.pos_zip64extrainfo > 0) 1715 if(zi->ci.pos_zip64extrainfo > 0)
1717 { 1716 {
1718 // Update the size in the ZIP64 extended field. 1717 // Update the size in the ZIP64 extended field.
1719 if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0) 1718 if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0)
1720 err = ZIP_ERRNO; 1719 err = ZIP_ERRNO;
1721 1720
1722 if (err==ZIP_OK) /* compressed size, unknown */ 1721 if (err==ZIP_OK) /* compressed size, unknown */
1723 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompr essed_size, 8); 1722 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompr essed_size, 8);
1724 1723
1725 if (err==ZIP_OK) /* uncompressed size, unknown */ 1724 if (err==ZIP_OK) /* uncompressed size, unknown */
1726 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compres sed_size, 8); 1725 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compres sed_size, 8);
1727 } 1726 }
1728 else
1729 err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for z ip64 info -> fatal
1730 } 1727 }
1731 else 1728 else
1732 { 1729 {
1733 if (err==ZIP_OK) /* compressed size, unknown */ 1730 if (err==ZIP_OK) /* compressed size, unknown */
1734 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compresse d_size,4); 1731 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compresse d_size,4);
1735 1732
1736 if (err==ZIP_OK) /* uncompressed size, unknown */ 1733 if (err==ZIP_OK) /* uncompressed size, unknown */
1737 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompres sed_size,4); 1734 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompres sed_size,4);
1738 } 1735 }
1739 1736
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_central dir,4); 1845 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_central dir,4);
1849 1846
1850 if (err==ZIP_OK) /* offset of start of central directory with respect to the s tarting disk number */ 1847 if (err==ZIP_OK) /* offset of start of central directory with respect to the s tarting disk number */
1851 { 1848 {
1852 ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; 1849 ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
1853 if(pos >= 0xffffffff) 1850 if(pos >= 0xffffffff)
1854 { 1851 {
1855 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xfffffff f,4); 1852 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xfffffff f,4);
1856 } 1853 }
1857 else 1854 else
1858 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centrald ir_pos_inzip - zi->add_position_when_writting_offset),4); 1855 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLo ng)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);
1859 } 1856 }
1860 1857
1861 return err; 1858 return err;
1862 } 1859 }
1863 1860
1864 int Write_GlobalComment(zip64_internal* zi, const char* global_comment) 1861 int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
1865 { 1862 {
1866 int err = ZIP_OK; 1863 int err = ZIP_OK;
1867 uInt size_global_comment = 0; 1864 uInt size_global_comment = 0;
1868 1865
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 err = ZIP_ERRNO; 1912 err = ZIP_ERRNO;
1916 } 1913 }
1917 1914
1918 size_centraldir += ldi->filled_in_this_block; 1915 size_centraldir += ldi->filled_in_this_block;
1919 ldi = ldi->next_datablock; 1916 ldi = ldi->next_datablock;
1920 } 1917 }
1921 } 1918 }
1922 free_linkedlist(&(zi->central_dir)); 1919 free_linkedlist(&(zi->central_dir));
1923 1920
1924 pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; 1921 pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
1925 if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) 1922 if(pos >= 0xffffffff)
1926 { 1923 {
1927 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); 1924 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
1928 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos _inzip); 1925 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos _inzip);
1929 1926
1930 Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); 1927 Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
1931 } 1928 }
1932 1929
1933 if (err==ZIP_OK) 1930 if (err==ZIP_OK)
1934 err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_po s_inzip); 1931 err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_po s_inzip);
1935 1932
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 1995
1999 retVal = ZIP_OK; 1996 retVal = ZIP_OK;
2000 } 1997 }
2001 else 1998 else
2002 retVal = ZIP_ERRNO; 1999 retVal = ZIP_ERRNO;
2003 2000
2004 TRYFREE(pNewHeader); 2001 TRYFREE(pNewHeader);
2005 2002
2006 return retVal; 2003 return retVal;
2007 } 2004 }
OLDNEW
« no previous file with comments | « third_party/zlib/contrib/minizip/unzip.c ('k') | third_party/zlib/crc32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698