VirtualBox

Changeset 50526 in vbox


Ignore:
Timestamp:
Feb 20, 2014 5:01:32 PM (11 years ago)
Author:
vboxsync
Message:

Storage/VHDX: Finally commit and enable CRC-32c checksum validation after finding the cause for the failing checksum computation. The whole 4KB space needs to get used for the checksum though the header is only 512 bytes

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/crc.h

    r44528 r50526  
    153153/** @} */
    154154
     155
     156/** @defgroup grp_rt_crc32c  CRC-32C
     157 * @{ */
     158/**
     159 * Calculate CRC-32C for a memory block.
     160 *
     161 * @returns CRC-32C for the memory block.
     162 * @param   pv      Pointer to the memory block.
     163 * @param   cb      Size of the memory block in bytes.
     164 */
     165RTDECL(uint32_t)    RTCrc32C(const void *pv, size_t cb);
     166
     167/**
     168 * Start a multiblock CRC-32 calculation.
     169 *
     170 * @returns Start CRC-32.
     171 */
     172RTDECL(uint32_t)    RTCrc32CStart(void);
     173
     174/**
     175 * Processes a multiblock of a CRC-32C calculation.
     176 *
     177 * @returns Intermediate CRC-32C value.
     178 * @param   uCRC32C Current CRC-32C intermediate value.
     179 * @param   pv      The data block to process.
     180 * @param   cb      The size of the data block in bytes.
     181 */
     182RTDECL(uint32_t)    RTCrc32CProcess(uint32_t uCRC32C, const void *pv, size_t cb);
     183
     184/**
     185 * Complete a multiblock CRC-32 calculation.
     186 *
     187 * @returns CRC-32 value.
     188 * @param   uCRC32  Current CRC-32 intermediate value.
     189 */
     190RTDECL(uint32_t)    RTCrc32CFinish(uint32_t uCRC32);
     191
     192/** @} */
     193
    155194/** @} */
    156195
  • trunk/include/iprt/mangling.h

    r50456 r50526  
    319319# define RTCrc32Process                                 RT_MANGLER(RTCrc32Process)
    320320# define RTCrc32Start                                   RT_MANGLER(RTCrc32Start)
     321# define RTCrc32C                                       RT_MANGLER(RTCrc32C)
     322# define RTCrc32CFinish                                 RT_MANGLER(RTCrc32CFinish)
     323# define RTCrc32CProcess                                RT_MANGLER(RTCrc32CProcess)
     324# define RTCrc32CStart                                  RT_MANGLER(RTCrc32CStart)
    321325# define RTCrc64                                        RT_MANGLER(RTCrc64)
    322326# define RTCrc64Finish                                  RT_MANGLER(RTCrc64Finish)
  • trunk/src/VBox/Runtime/Makefile.kmk

    r50458 r50526  
    264264        common/checksum/adler32.cpp \
    265265        common/checksum/crc32.cpp \
     266        common/checksum/crc32c.cpp \
    266267        common/checksum/crc64.cpp \
    267268        common/checksum/md5.cpp \
  • trunk/src/VBox/Storage/VHDX.cpp

    r48861 r50526  
    10641064            u32ChkSumSaved = pHdr1->u32Checksum;
    10651065            pHdr1->u32Checksum = 0;
    1066             //u32ChkSum = RTCrc32C(pHdr1, RT_OFFSETOF(VhdxHeader, u8Reserved[502]));
     1066            u32ChkSum = RTCrc32C(pHdr1, sizeof(VhdxHeader));
    10671067
    10681068            if (   pHdr1->u32Signature == VHDX_HEADER_SIGNATURE
    1069                 /*&& u32ChkSum == u32ChkSumSaved*/)
     1069                && u32ChkSum == u32ChkSumSaved)
    10701070                fHdr1Valid = true;
    10711071        }
     
    10811081            u32ChkSumSaved = pHdr2->u32Checksum;
    10821082            pHdr2->u32Checksum = 0;
    1083             //u32ChkSum = RTCrc32C(pHdr2, RT_OFFSETOF(VhdxHeader, u8Reserved[502]));
     1083            u32ChkSum = RTCrc32C(pHdr2, sizeof(VhdxHeader));
    10841084
    10851085            if (   pHdr2->u32Signature == VHDX_HEADER_SIGNATURE
    1086                 /*&& u32ChkSum == u32ChkSumSaved*/)
     1086                && u32ChkSum == u32ChkSumSaved)
    10871087                fHdr2Valid = true;
    10881088        }
     
    15711571
    15721572            /* Verify the region table integrity. */
    1573             //u32ChkSum = RTCrc32C(pbRegionTbl, VHDX_REGION_TBL_SIZE_MAX);
     1573            u32ChkSum = RTCrc32C(pbRegionTbl, VHDX_REGION_TBL_SIZE_MAX);
    15741574
    15751575            if (RegionTblHdr.u32Signature != VHDX_REGION_TBL_HDR_SIGNATURE)
     
    15771577                               "VHDX: Invalid signature for region table header of image \'%s\'",
    15781578                               pImage->pszFilename);
    1579 #if 0
    15801579            else if (u32ChkSum != RegionTblHdr.u32Checksum)
    15811580                rc = vdIfError(pImage->pIfError, VERR_VD_GEN_INVALID_HEADER, RT_SRC_POS,
    15821581                               "VHDX: CRC32 checksum mismatch for the region table of image \'%s\' (expected %#x got %#x)",
    15831582                               pImage->pszFilename, RegionTblHdr.u32Checksum, u32ChkSum);
    1584 #endif
    15851583            else if (RegionTblHdr.u32EntryCount > VHDX_REGION_TBL_HDR_ENTRY_COUNT_MAX)
    15861584                rc = vdIfError(pImage->pIfError, VERR_VD_GEN_INVALID_HEADER, RT_SRC_POS,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette