aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/zip_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/zip_extractor.c')
-rw-r--r--src/plugins/zip_extractor.c58
1 files changed, 22 insertions, 36 deletions
diff --git a/src/plugins/zip_extractor.c b/src/plugins/zip_extractor.c
index c7bc936..f884e74 100644
--- a/src/plugins/zip_extractor.c
+++ b/src/plugins/zip_extractor.c
@@ -152,14 +152,13 @@ EXTRACTOR_zip_extract (const unsigned char *data,
152 pos = &data[offset--]; 152 pos = &data[offset--];
153 if (offset == stop) 153 if (offset == stop)
154 { 154 {
155
156#if DEBUG_EXTRACT_ZIP 155#if DEBUG_EXTRACT_ZIP
157 fprintf (stderr, 156 fprintf (stderr,
158 "Did not find end of central directory structure signature. offset: %i\n", 157 "Did not find end of central directory structure signature. offset: %i\n",
159 offset); 158 offset);
160 159
161#endif /* */ 160#endif
162 return 0; 161 return 0;
163 } 162 }
164 163
165 /* offset should now point to the start of the end-of-central directory structure */ 164 /* offset should now point to the start of the end-of-central directory structure */
@@ -180,26 +179,20 @@ EXTRACTOR_zip_extract (const unsigned char *data,
180 filecomment[filecomment_length] = '\0'; 179 filecomment[filecomment_length] = '\0';
181 } 180 }
182 } 181 }
182
183#if DEBUG_EXTRACT_ZIP
183 if ((0 != pos[4]) && (0 != pos[5])) 184 if ((0 != pos[4]) && (0 != pos[5]))
184 { 185 fprintf (stderr,
186 "WARNING: This seems to be the last disk in a multi-volume"
187 " ZIP archive, and so this might not work.\n");
188#endif
185 189
186#if DEBUG_EXTRACT_ZIP 190#if DEBUG_EXTRACT_ZIP
187 fprintf (stderr,
188 "WARNING: This seems to be the last disk in a multi-volume"
189 " ZIP archive, and so this might not work.\n");
190
191#endif /* */
192 }
193 if ((pos[8] != pos[10]) && (pos[9] != pos[11])) 191 if ((pos[8] != pos[10]) && (pos[9] != pos[11]))
194 { 192 fprintf (stderr,
195 193 "WARNING: May not be able to find all the files in this"
196#if DEBUG_EXTRACT_ZIP 194 " ZIP archive (no multi-volume support right now).\n");
197 fprintf (stderr, 195#endif
198 "WARNING: May not be able to find all the files in this"
199 " ZIP archive (no multi-volume support right now).\n");
200
201#endif /* */
202 }
203 entry_total = pos[10] + (pos[11] << 8); 196 entry_total = pos[10] + (pos[11] << 8);
204 entry_count = 0; 197 entry_count = 0;
205 198
@@ -246,18 +239,17 @@ EXTRACTOR_zip_extract (const unsigned char *data,
246 */ 239 */
247 if (!(('P' == pos[0]) && ('K' == pos[1]) && (0x01 == pos[2]) 240 if (!(('P' == pos[0]) && ('K' == pos[1]) && (0x01 == pos[2])
248 && (0x02 == pos[3]))) 241 && (0x02 == pos[3])))
249 { 242 {
250
251#if DEBUG_EXTRACT_ZIP 243#if DEBUG_EXTRACT_ZIP
252 fprintf (stderr, 244 fprintf (stderr,
253 "Did not find central directory structure signature. offset: %i\n", 245 "Did not find central directory structure signature. offset: %i\n",
254 offset); 246 offset);
255 247
256#endif 248#endif
257 if (filecomment != NULL) 249 if (filecomment != NULL)
258 free (filecomment); 250 free (filecomment);
259 return 0; 251 return 0;
260 } 252 }
261 start = NULL; 253 start = NULL;
262 info = NULL; 254 info = NULL;
263 255
@@ -278,8 +270,7 @@ EXTRACTOR_zip_extract (const unsigned char *data,
278 fprintf (stderr, "Found filename length %i Comment length: %i\n", 270 fprintf (stderr, "Found filename length %i Comment length: %i\n",
279 name_length, comment_length); 271 name_length, comment_length);
280 272
281#endif /* */ 273#endif
282
283 /* yay, finally get filenames */ 274 /* yay, finally get filenames */
284 if (start == NULL) 275 if (start == NULL)
285 { 276 {
@@ -316,8 +307,7 @@ EXTRACTOR_zip_extract (const unsigned char *data,
316 pos = &data[offset]; 307 pos = &data[offset];
317 /* check for next header entry (0x02014b50) or (0x06054b50) if at end */ 308 /* check for next header entry (0x02014b50) or (0x06054b50) if at end */
318 if (('P' != pos[0]) && ('K' != pos[1])) 309 if (('P' != pos[0]) && ('K' != pos[1]))
319 { 310 {
320
321#if DEBUG_EXTRACT_ZIP 311#if DEBUG_EXTRACT_ZIP
322 fprintf (stderr, 312 fprintf (stderr,
323 "Did not find next header in central directory.\n"); 313 "Did not find next header in central directory.\n");
@@ -345,15 +335,11 @@ EXTRACTOR_zip_extract (const unsigned char *data,
345 335
346 /* TODO: should this return an error? indicates corrupt zipfile (or 336 /* TODO: should this return an error? indicates corrupt zipfile (or
347 disk missing in middle of multi-disk)? */ 337 disk missing in middle of multi-disk)? */
348 if (entry_count != entry_total)
349 {
350
351#if DEBUG_EXTRACT_ZIP 338#if DEBUG_EXTRACT_ZIP
352 fprintf (stderr, 339 if (entry_count != entry_total)
353 "WARNING: Did not find all of the zipfile entries that we should have.\n"); 340 fprintf (stderr,
354 341 "WARNING: Did not find all of the zipfile entries that we should have.\n");
355#endif /* */ 342#endif
356 }
357 343
358 ret = proc (proc_cls, 344 ret = proc (proc_cls,
359 "zip", 345 "zip",