aboutsummaryrefslogtreecommitdiff
path: root/contrib/minizip/mztools.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/minizip/mztools.c')
-rw-r--r--contrib/minizip/mztools.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c
index c8d2375..f86c1e7 100644
--- a/contrib/minizip/mztools.c
+++ b/contrib/minizip/mztools.c
@@ -5,6 +5,9 @@
5*/ 5*/
6 6
7/* Code */ 7/* Code */
8#ifndef _CRT_SECURE_NO_WARNINGS
9# define _CRT_SECURE_NO_WARNINGS
10#endif
8#include <stdio.h> 11#include <stdio.h>
9#include <stdlib.h> 12#include <stdlib.h>
10#include <string.h> 13#include <string.h>
@@ -140,28 +143,28 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
140 143
141 /* Central directory entry */ 144 /* Central directory entry */
142 { 145 {
143 char header[46]; 146 char central[46];
144 char* comment = ""; 147 char* comment = "";
145 int comsize = (int) strlen(comment); 148 int comsize = (int) strlen(comment);
146 WRITE_32(header, 0x02014b50); 149 WRITE_32(central, 0x02014b50);
147 WRITE_16(header + 4, version); 150 WRITE_16(central + 4, version);
148 WRITE_16(header + 6, version); 151 WRITE_16(central + 6, version);
149 WRITE_16(header + 8, gpflag); 152 WRITE_16(central + 8, gpflag);
150 WRITE_16(header + 10, method); 153 WRITE_16(central + 10, method);
151 WRITE_16(header + 12, filetime); 154 WRITE_16(central + 12, filetime);
152 WRITE_16(header + 14, filedate); 155 WRITE_16(central + 14, filedate);
153 WRITE_32(header + 16, crc); 156 WRITE_32(central + 16, crc);
154 WRITE_32(header + 20, cpsize); 157 WRITE_32(central + 20, cpsize);
155 WRITE_32(header + 24, uncpsize); 158 WRITE_32(central + 24, uncpsize);
156 WRITE_16(header + 28, fnsize); 159 WRITE_16(central + 28, fnsize);
157 WRITE_16(header + 30, extsize); 160 WRITE_16(central + 30, extsize);
158 WRITE_16(header + 32, comsize); 161 WRITE_16(central + 32, comsize);
159 WRITE_16(header + 34, 0); /* disk # */ 162 WRITE_16(central + 34, 0); /* disk # */
160 WRITE_16(header + 36, 0); /* int attrb */ 163 WRITE_16(central + 36, 0); /* int attrb */
161 WRITE_32(header + 38, 0); /* ext attrb */ 164 WRITE_32(central + 38, 0); /* ext attrb */
162 WRITE_32(header + 42, currentOffset); 165 WRITE_32(central + 42, currentOffset);
163 /* Header */ 166 /* Header */
164 if (fwrite(header, 1, 46, fpOutCD) == 46) { 167 if (fwrite(central, 1, 46, fpOutCD) == 46) {
165 offsetCD += 46; 168 offsetCD += 46;
166 169
167 /* Filename */ 170 /* Filename */
@@ -215,23 +218,23 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
215 /* Final central directory */ 218 /* Final central directory */
216 { 219 {
217 int entriesZip = entries; 220 int entriesZip = entries;
218 char header[22]; 221 char end[22];
219 char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; 222 char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
220 int comsize = (int) strlen(comment); 223 int comsize = (int) strlen(comment);
221 if (entriesZip > 0xffff) { 224 if (entriesZip > 0xffff) {
222 entriesZip = 0xffff; 225 entriesZip = 0xffff;
223 } 226 }
224 WRITE_32(header, 0x06054b50); 227 WRITE_32(end, 0x06054b50);
225 WRITE_16(header + 4, 0); /* disk # */ 228 WRITE_16(end + 4, 0); /* disk # */
226 WRITE_16(header + 6, 0); /* disk # */ 229 WRITE_16(end + 6, 0); /* disk # */
227 WRITE_16(header + 8, entriesZip); /* hack */ 230 WRITE_16(end + 8, entriesZip); /* hack */
228 WRITE_16(header + 10, entriesZip); /* hack */ 231 WRITE_16(end + 10, entriesZip); /* hack */
229 WRITE_32(header + 12, offsetCD); /* size of CD */ 232 WRITE_32(end + 12, offsetCD); /* size of CD */
230 WRITE_32(header + 16, offset); /* offset to CD */ 233 WRITE_32(end + 16, offset); /* offset to CD */
231 WRITE_16(header + 20, comsize); /* comment */ 234 WRITE_16(end + 20, comsize); /* comment */
232 235
233 /* Header */ 236 /* Header */
234 if (fwrite(header, 1, 22, fpOutCD) == 22) { 237 if (fwrite(end, 1, 22, fpOutCD) == 22) {
235 238
236 /* Comment field */ 239 /* Comment field */
237 if (comsize > 0) { 240 if (comsize > 0) {