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

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

Issue 2084863002: 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/mztools.h ('k') | third_party/zlib/contrib/minizip/unzip.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 /* 1 /*
2 Additional tools for Minizip 2 Additional tools for Minizip
3 Code: Xavier Roche '2004 3 Code: Xavier Roche '2004
4 License: Same as ZLIB (www.gzip.org) 4 License: Same as ZLIB (www.gzip.org)
5 */ 5 */
6 6
7 /* Code */ 7 /* Code */
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 24 matching lines...) Expand all
35 uLong* bytesRecovered; 35 uLong* bytesRecovered;
36 { 36 {
37 int err = Z_OK; 37 int err = Z_OK;
38 FILE* fpZip = fopen(file, "rb"); 38 FILE* fpZip = fopen(file, "rb");
39 FILE* fpOut = fopen(fileOut, "wb"); 39 FILE* fpOut = fopen(fileOut, "wb");
40 FILE* fpOutCD = fopen(fileOutTmp, "wb"); 40 FILE* fpOutCD = fopen(fileOutTmp, "wb");
41 if (fpZip != NULL && fpOut != NULL) { 41 if (fpZip != NULL && fpOut != NULL) {
42 int entries = 0; 42 int entries = 0;
43 uLong totalBytes = 0; 43 uLong totalBytes = 0;
44 char header[30]; 44 char header[30];
45 char filename[256]; 45 char filename[1024];
46 char extra[1024]; 46 char extra[1024];
47 int offset = 0; 47 int offset = 0;
48 int offsetCD = 0; 48 int offsetCD = 0;
49 while ( fread(header, 1, 30, fpZip) == 30 ) { 49 while ( fread(header, 1, 30, fpZip) == 30 ) {
50 int currentOffset = offset; 50 int currentOffset = offset;
51 51
52 /* File entry */ 52 /* File entry */
53 if (READ_32(header) == 0x04034b50) { 53 if (READ_32(header) == 0x04034b50) {
54 unsigned int version = READ_16(header + 4); 54 unsigned int version = READ_16(header + 4);
55 unsigned int gpflag = READ_16(header + 6); 55 unsigned int gpflag = READ_16(header + 6);
(...skipping 10 matching lines...) Expand all
66 /* Header */ 66 /* Header */
67 if (fwrite(header, 1, 30, fpOut) == 30) { 67 if (fwrite(header, 1, 30, fpOut) == 30) {
68 offset += 30; 68 offset += 30;
69 } else { 69 } else {
70 err = Z_ERRNO; 70 err = Z_ERRNO;
71 break; 71 break;
72 } 72 }
73 73
74 /* Filename */ 74 /* Filename */
75 if (fnsize > 0) { 75 if (fnsize > 0) {
76 if (fread(filename, 1, fnsize, fpZip) == fnsize) { 76 if (fnsize < sizeof(filename)) {
77 if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { 77 if (fread(filename, 1, fnsize, fpZip) == fnsize) {
78 offset += fnsize; 78 if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {
79 offset += fnsize;
80 } else {
81 err = Z_ERRNO;
82 break;
83 }
79 } else { 84 } else {
80 err = Z_ERRNO; 85 err = Z_ERRNO;
81 break; 86 break;
82 } 87 }
83 } else { 88 } else {
84 err = Z_ERRNO; 89 err = Z_ERRNO;
85 break; 90 break;
86 } 91 }
87 } else { 92 } else {
88 err = Z_STREAM_ERROR; 93 err = Z_STREAM_ERROR;
89 break; 94 break;
90 } 95 }
91 96
92 /* Extra field */ 97 /* Extra field */
93 if (extsize > 0) { 98 if (extsize > 0) {
94 if (fread(extra, 1, extsize, fpZip) == extsize) { 99 if (extsize < sizeof(extra)) {
95 if (fwrite(extra, 1, extsize, fpOut) == extsize) { 100 if (fread(extra, 1, extsize, fpZip) == extsize) {
96 offset += extsize; 101 if (fwrite(extra, 1, extsize, fpOut) == extsize) {
102 offset += extsize;
103 } else {
104 err = Z_ERRNO;
105 break;
106 }
97 } else { 107 } else {
98 err = Z_ERRNO; 108 err = Z_ERRNO;
99 break; 109 break;
100 } 110 }
101 } else { 111 } else {
102 err = Z_ERRNO; 112 err = Z_ERRNO;
103 break; 113 break;
104 } 114 }
105 } 115 }
106 116
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 282 }
273 if (bytesRecovered != NULL) { 283 if (bytesRecovered != NULL) {
274 *bytesRecovered = totalBytes; 284 *bytesRecovered = totalBytes;
275 } 285 }
276 } 286 }
277 } else { 287 } else {
278 err = Z_STREAM_ERROR; 288 err = Z_STREAM_ERROR;
279 } 289 }
280 return err; 290 return err;
281 } 291 }
OLDNEW
« no previous file with comments | « third_party/zlib/contrib/minizip/mztools.h ('k') | third_party/zlib/contrib/minizip/unzip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698