Changeset 48836 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Oct 3, 2013 1:31:39 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/zip/gzipvfs.cpp
r47359 r48836 686 686 { 687 687 AssertPtrReturn(hVfsIosIn, VERR_INVALID_HANDLE); 688 AssertReturn(! fFlags, VERR_INVALID_PARAMETER);688 AssertReturn(!(fFlags & ~RTZIPGZIPDECOMP_F_ALLOW_ZLIB_HDR), VERR_INVALID_PARAMETER); 689 689 AssertPtrReturn(phVfsIosOut, VERR_INVALID_POINTER); 690 690 … … 710 710 memset(&pThis->Zlib, 0, sizeof(pThis->Zlib)); 711 711 pThis->Zlib.opaque = pThis; 712 rc = inflateInit2(&pThis->Zlib, MAX_WBITS + 16 /* autodetect gzip header */); 712 rc = inflateInit2(&pThis->Zlib, 713 fFlags & RTZIPGZIPDECOMP_F_ALLOW_ZLIB_HDR 714 ? MAX_WBITS 715 : MAX_WBITS + 16 /* autodetect gzip header */); 713 716 if (rc >= 0) 714 717 { 715 718 /* 716 719 * Read the gzip header from the input stream to check that it's 717 * a gzip stream .720 * a gzip stream as specified by the user. 718 721 * 719 722 * Note!. Since we've told zlib to check for the gzip header, we … … 726 729 /* Validate the header and make a copy of it. */ 727 730 PCRTZIPGZIPHDR pHdr = (PCRTZIPGZIPHDR)pThis->abBuffer; 728 if ( pHdr->bId1 != RTZIPGZIPHDR_ID1 729 || pHdr->bId2 != RTZIPGZIPHDR_ID2 730 || pHdr->fFlags & ~RTZIPGZIPHDR_FLG_VALID_MASK) 731 if ( pHdr->bId1 == RTZIPGZIPHDR_ID1 732 && pHdr->bId2 == RTZIPGZIPHDR_ID2 733 && !(pHdr->fFlags & ~RTZIPGZIPHDR_FLG_VALID_MASK)) 734 { 735 if (pHdr->bCompressionMethod == RTZIPGZIPHDR_CM_DEFLATE) 736 rc = VINF_SUCCESS; 737 else 738 rc = VERR_ZIP_UNSUPPORTED_METHOD; 739 } 740 else if ( (fFlags & RTZIPGZIPDECOMP_F_ALLOW_ZLIB_HDR) 741 && (RT_MAKE_U16(pHdr->bId2, pHdr->bId1) % 31) == 0 742 && (pHdr->bId1 & 0xf) == RTZIPGZIPHDR_CM_DEFLATE ) 743 { 744 pHdr = NULL; 745 rc = VINF_SUCCESS; 746 } 747 else 731 748 rc = VERR_ZIP_BAD_HEADER; 732 else if (pHdr->bCompressionMethod != RTZIPGZIPHDR_CM_DEFLATE) 733 rc = VERR_ZIP_UNSUPPORTED_METHOD; 734 else 749 if (RT_SUCCESS(rc)) 735 750 { 736 pThis->Hdr = *pHdr;737 751 pThis->Zlib.avail_in = sizeof(RTZIPGZIPHDR); 738 752 pThis->Zlib.next_in = &pThis->abBuffer[0]; 739 740 /* Parse on if there are names or comments. */ 741 if (pHdr->fFlags & (RTZIPGZIPHDR_FLG_NAME | RTZIPGZIPHDR_FLG_COMMENT)) 753 if (pHdr) 742 754 { 743 /** @todo Can implement this when someone needs the 744 * name or comment for something useful. */ 755 pThis->Hdr = *pHdr; 756 /* Parse on if there are names or comments. */ 757 if (pHdr->fFlags & (RTZIPGZIPHDR_FLG_NAME | RTZIPGZIPHDR_FLG_COMMENT)) 758 { 759 /** @todo Can implement this when someone needs the 760 * name or comment for something useful. */ 761 } 745 762 } 746 763 if (RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.