diff options
Diffstat (limited to 'contrib/minizip')
| -rw-r--r-- | contrib/minizip/unzip.c | 2 | ||||
| -rw-r--r-- | contrib/minizip/zip.c | 90 |
2 files changed, 47 insertions, 45 deletions
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index 78a8473e..ff71a474 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
| @@ -315,7 +315,7 @@ local uLong unzlocal_SearchCentralDir(fin) | |||
| 315 | if (fread(buf,(uInt)uReadSize,1,fin)!=1) | 315 | if (fread(buf,(uInt)uReadSize,1,fin)!=1) |
| 316 | break; | 316 | break; |
| 317 | 317 | ||
| 318 | for (i=0;i<(int)uReadSize-3;i++) | 318 | for (i=(int)uReadSize-3; (i--)>0;) |
| 319 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && | 319 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && |
| 320 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) | 320 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) |
| 321 | { | 321 | { |
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index ddb23348..0cae64ab 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c | |||
| @@ -242,6 +242,8 @@ local int write_datablock(fout,ll) | |||
| 242 | Outputs a long in LSB order to the given file | 242 | Outputs a long in LSB order to the given file |
| 243 | nbByte == 1, 2 or 4 (byte, short or long) | 243 | nbByte == 1, 2 or 4 (byte, short or long) |
| 244 | */ | 244 | */ |
| 245 | |||
| 246 | local int ziplocal_putValue OF((FILE *file, uLong x, int nbByte)); | ||
| 245 | local int ziplocal_putValue (file, x, nbByte) | 247 | local int ziplocal_putValue (file, x, nbByte) |
| 246 | FILE *file; | 248 | FILE *file; |
| 247 | uLong x; | 249 | uLong x; |
| @@ -259,7 +261,7 @@ local int ziplocal_putValue (file, x, nbByte) | |||
| 259 | return ZIP_OK; | 261 | return ZIP_OK; |
| 260 | } | 262 | } |
| 261 | 263 | ||
| 262 | 264 | local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); | |
| 263 | local void ziplocal_putValue_inmemory (dest, x, nbByte) | 265 | local void ziplocal_putValue_inmemory (dest, x, nbByte) |
| 264 | void* dest; | 266 | void* dest; |
| 265 | uLong x; | 267 | uLong x; |
| @@ -390,34 +392,34 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, | |||
| 390 | zi->ci.pos_local_header = ftell(zi->filezip); | 392 | zi->ci.pos_local_header = ftell(zi->filezip); |
| 391 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + | 393 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + |
| 392 | size_extrafield_global + size_comment; | 394 | size_extrafield_global + size_comment; |
| 393 | zi->ci.central_header = (char*)ALLOC(zi->ci.size_centralheader); | 395 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); |
| 394 | 396 | ||
| 395 | ziplocal_putValue_inmemory(zi->ci.central_header,CENTRALHEADERMAGIC,4); | 397 | ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); |
| 396 | /* version info */ | 398 | /* version info */ |
| 397 | ziplocal_putValue_inmemory(zi->ci.central_header+4,VERSIONMADEBY,2); | 399 | ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); |
| 398 | ziplocal_putValue_inmemory(zi->ci.central_header+6,20,2); | 400 | ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); |
| 399 | ziplocal_putValue_inmemory(zi->ci.central_header+8,zi->ci.flag,2); | 401 | ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); |
| 400 | ziplocal_putValue_inmemory(zi->ci.central_header+10,zi->ci.method,2); | 402 | ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); |
| 401 | ziplocal_putValue_inmemory(zi->ci.central_header+12,zi->ci.dosDate,4); | 403 | ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); |
| 402 | ziplocal_putValue_inmemory(zi->ci.central_header+16,0,4); /*crc*/ | 404 | ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ |
| 403 | ziplocal_putValue_inmemory(zi->ci.central_header+20,0,4); /*compr size*/ | 405 | ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ |
| 404 | ziplocal_putValue_inmemory(zi->ci.central_header+24,0,4); /*uncompr size*/ | 406 | ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ |
| 405 | ziplocal_putValue_inmemory(zi->ci.central_header+28,size_filename,2); | 407 | ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); |
| 406 | ziplocal_putValue_inmemory(zi->ci.central_header+30,size_extrafield_global,2); | 408 | ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); |
| 407 | ziplocal_putValue_inmemory(zi->ci.central_header+32,size_comment,2); | 409 | ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); |
| 408 | ziplocal_putValue_inmemory(zi->ci.central_header+34,0,2); /*disk nm start*/ | 410 | ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ |
| 409 | 411 | ||
| 410 | if (zipfi==NULL) | 412 | if (zipfi==NULL) |
| 411 | ziplocal_putValue_inmemory(zi->ci.central_header+36,0,2); | 413 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); |
| 412 | else | 414 | else |
| 413 | ziplocal_putValue_inmemory(zi->ci.central_header+36,zipfi->internal_fa,2); | 415 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); |
| 414 | 416 | ||
| 415 | if (zipfi==NULL) | 417 | if (zipfi==NULL) |
| 416 | ziplocal_putValue_inmemory(zi->ci.central_header+38,0,4); | 418 | ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); |
| 417 | else | 419 | else |
| 418 | ziplocal_putValue_inmemory(zi->ci.central_header+38,zipfi->external_fa,4); | 420 | ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); |
| 419 | 421 | ||
| 420 | ziplocal_putValue_inmemory(zi->ci.central_header+42,zi->ci.pos_local_header,4); | 422 | ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header,4); |
| 421 | 423 | ||
| 422 | for (i=0;i<size_filename;i++) | 424 | for (i=0;i<size_filename;i++) |
| 423 | *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); | 425 | *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); |
| @@ -433,25 +435,25 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, | |||
| 433 | return ZIP_INTERNALERROR; | 435 | return ZIP_INTERNALERROR; |
| 434 | 436 | ||
| 435 | /* write the local header */ | 437 | /* write the local header */ |
| 436 | err = ziplocal_putValue(zi->filezip,LOCALHEADERMAGIC,4); | 438 | err = ziplocal_putValue(zi->filezip,(uLong)LOCALHEADERMAGIC,4); |
| 437 | 439 | ||
| 438 | if (err==ZIP_OK) | 440 | if (err==ZIP_OK) |
| 439 | err = ziplocal_putValue(zi->filezip,20,2);/* version needed to extract */ | 441 | err = ziplocal_putValue(zi->filezip,(uLong)20,2);/* version needed to extract */ |
| 440 | if (err==ZIP_OK) | 442 | if (err==ZIP_OK) |
| 441 | err = ziplocal_putValue(zi->filezip,zi->ci.flag,2); | 443 | err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.flag,2); |
| 442 | 444 | ||
| 443 | if (err==ZIP_OK) | 445 | if (err==ZIP_OK) |
| 444 | err = ziplocal_putValue(zi->filezip,zi->ci.method,2); | 446 | err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.method,2); |
| 445 | 447 | ||
| 446 | if (err==ZIP_OK) | 448 | if (err==ZIP_OK) |
| 447 | err = ziplocal_putValue(zi->filezip,zi->ci.dosDate,4); | 449 | err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.dosDate,4); |
| 448 | 450 | ||
| 449 | if (err==ZIP_OK) | 451 | if (err==ZIP_OK) |
| 450 | err = ziplocal_putValue(zi->filezip,0,4); /* crc 32, unknown */ | 452 | err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* crc 32, unknown */ |
| 451 | if (err==ZIP_OK) | 453 | if (err==ZIP_OK) |
| 452 | err = ziplocal_putValue(zi->filezip,0,4); /* compressed size, unknown */ | 454 | err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* compressed size, unknown */ |
| 453 | if (err==ZIP_OK) | 455 | if (err==ZIP_OK) |
| 454 | err = ziplocal_putValue(zi->filezip,0,4); /* uncompressed size, unknown */ | 456 | err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* uncompressed size, unknown */ |
| 455 | 457 | ||
| 456 | if (err==ZIP_OK) | 458 | if (err==ZIP_OK) |
| 457 | err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); | 459 | err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); |
| @@ -481,7 +483,7 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, | |||
| 481 | zi->ci.stream.opaque = (voidpf)0; | 483 | zi->ci.stream.opaque = (voidpf)0; |
| 482 | 484 | ||
| 483 | err = deflateInit2(&zi->ci.stream, level, | 485 | err = deflateInit2(&zi->ci.stream, level, |
| 484 | Z_DEFLATED, -MAX_WBITS, /*DEF_MEM_LEVEL*/8, 0); | 486 | Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0); |
| 485 | 487 | ||
| 486 | if (err==Z_OK) | 488 | if (err==Z_OK) |
| 487 | zi->ci.stream_initialised = 1; | 489 | zi->ci.stream_initialised = 1; |
| @@ -528,7 +530,7 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len) | |||
| 528 | { | 530 | { |
| 529 | uLong uTotalOutBefore = zi->ci.stream.total_out; | 531 | uLong uTotalOutBefore = zi->ci.stream.total_out; |
| 530 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); | 532 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); |
| 531 | zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ; | 533 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; |
| 532 | 534 | ||
| 533 | } | 535 | } |
| 534 | else | 536 | else |
| @@ -585,7 +587,7 @@ extern int ZEXPORT zipCloseFileInZip (file) | |||
| 585 | } | 587 | } |
| 586 | uTotalOutBefore = zi->ci.stream.total_out; | 588 | uTotalOutBefore = zi->ci.stream.total_out; |
| 587 | err=deflate(&zi->ci.stream, Z_FINISH); | 589 | err=deflate(&zi->ci.stream, Z_FINISH); |
| 588 | zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ; | 590 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; |
| 589 | } | 591 | } |
| 590 | 592 | ||
| 591 | if (err==Z_STREAM_END) | 593 | if (err==Z_STREAM_END) |
| @@ -602,11 +604,11 @@ extern int ZEXPORT zipCloseFileInZip (file) | |||
| 602 | zi->ci.stream_initialised = 0; | 604 | zi->ci.stream_initialised = 0; |
| 603 | } | 605 | } |
| 604 | 606 | ||
| 605 | ziplocal_putValue_inmemory(zi->ci.central_header+16,zi->ci.crc32,4); /*crc*/ | 607 | ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)zi->ci.crc32,4); /*crc*/ |
| 606 | ziplocal_putValue_inmemory(zi->ci.central_header+20, | 608 | ziplocal_putValue_inmemory(zi->ci.central_header+20, |
| 607 | zi->ci.stream.total_out,4); /*compr size*/ | 609 | (uLong)zi->ci.stream.total_out,4); /*compr size*/ |
| 608 | ziplocal_putValue_inmemory(zi->ci.central_header+24, | 610 | ziplocal_putValue_inmemory(zi->ci.central_header+24, |
| 609 | zi->ci.stream.total_in,4); /*uncompr size*/ | 611 | (uLong)zi->ci.stream.total_in,4); /*uncompr size*/ |
| 610 | 612 | ||
| 611 | if (err==ZIP_OK) | 613 | if (err==ZIP_OK) |
| 612 | err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, | 614 | err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, |
| @@ -621,13 +623,13 @@ extern int ZEXPORT zipCloseFileInZip (file) | |||
| 621 | err = ZIP_ERRNO; | 623 | err = ZIP_ERRNO; |
| 622 | 624 | ||
| 623 | if (err==ZIP_OK) | 625 | if (err==ZIP_OK) |
| 624 | err = ziplocal_putValue(zi->filezip,zi->ci.crc32,4); /* crc 32, unknown */ | 626 | err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */ |
| 625 | 627 | ||
| 626 | if (err==ZIP_OK) /* compressed size, unknown */ | 628 | if (err==ZIP_OK) /* compressed size, unknown */ |
| 627 | err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_out,4); | 629 | err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4); |
| 628 | 630 | ||
| 629 | if (err==ZIP_OK) /* uncompressed size, unknown */ | 631 | if (err==ZIP_OK) /* uncompressed size, unknown */ |
| 630 | err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_in,4); | 632 | err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4); |
| 631 | 633 | ||
| 632 | if (fseek(zi->filezip, | 634 | if (fseek(zi->filezip, |
| 633 | cur_pos_inzip,SEEK_SET)!=0) | 635 | cur_pos_inzip,SEEK_SET)!=0) |
| @@ -682,26 +684,26 @@ extern int ZEXPORT zipClose (file, global_comment) | |||
| 682 | free_datablock(zi->central_dir.first_block); | 684 | free_datablock(zi->central_dir.first_block); |
| 683 | 685 | ||
| 684 | if (err==ZIP_OK) /* Magic End */ | 686 | if (err==ZIP_OK) /* Magic End */ |
| 685 | err = ziplocal_putValue(zi->filezip,ENDHEADERMAGIC,4); | 687 | err = ziplocal_putValue(zi->filezip,(uLong)ENDHEADERMAGIC,4); |
| 686 | 688 | ||
| 687 | if (err==ZIP_OK) /* number of this disk */ | 689 | if (err==ZIP_OK) /* number of this disk */ |
| 688 | err = ziplocal_putValue(zi->filezip,0,2); | 690 | err = ziplocal_putValue(zi->filezip,(uLong)0,2); |
| 689 | 691 | ||
| 690 | if (err==ZIP_OK) /* number of the disk with the start of the central directory */ | 692 | if (err==ZIP_OK) /* number of the disk with the start of the central directory */ |
| 691 | err = ziplocal_putValue(zi->filezip,0,2); | 693 | err = ziplocal_putValue(zi->filezip,(uLong)0,2); |
| 692 | 694 | ||
| 693 | if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ | 695 | if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ |
| 694 | err = ziplocal_putValue(zi->filezip,zi->number_entry,2); | 696 | err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); |
| 695 | 697 | ||
| 696 | if (err==ZIP_OK) /* total number of entries in the central dir */ | 698 | if (err==ZIP_OK) /* total number of entries in the central dir */ |
| 697 | err = ziplocal_putValue(zi->filezip,zi->number_entry,2); | 699 | err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); |
| 698 | 700 | ||
| 699 | if (err==ZIP_OK) /* size of the central directory */ | 701 | if (err==ZIP_OK) /* size of the central directory */ |
| 700 | err = ziplocal_putValue(zi->filezip,size_centraldir,4); | 702 | err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4); |
| 701 | 703 | ||
| 702 | if (err==ZIP_OK) /* offset of start of central directory with respect to the | 704 | if (err==ZIP_OK) /* offset of start of central directory with respect to the |
| 703 | starting disk number */ | 705 | starting disk number */ |
| 704 | err = ziplocal_putValue(zi->filezip,centraldir_pos_inzip ,4); | 706 | err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4); |
| 705 | 707 | ||
| 706 | if (err==ZIP_OK) /* zipfile comment length */ | 708 | if (err==ZIP_OK) /* zipfile comment length */ |
| 707 | err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); | 709 | err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); |
