VirtualBox

Changeset 46980 in vbox


Ignore:
Timestamp:
Jul 4, 2013 11:38:28 AM (12 years ago)
Author:
vboxsync
Message:

Deprecated the old manifest API. r=bird: IPRT does NOT use ugly C++ references, it pointers directly - no cloak and dagger pointers thank you. Please don't reformat if expressions into unreadability. RTDIGESTTYPE_UNKNOWN should be RTDIGESTTYPE_INVALID and there is actually no need to set output variables on failure, just check the status code.

Location:
trunk
Files:
4 edited

Legend:

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

    r45227 r46980  
    6161typedef enum RTDIGESTTYPE
    6262{
    63     /** unknown digest */
    64     RTDIGESTTYPE_UNKNOWN,
    65     /** CRC32 checksum */
    66     RTDIGESTTYPE_CRC32 = 1,
    67     /** CRC64 checksum */
     63    /** Invalid digest value. */
     64    RTDIGESTTYPE_INVALID = 0,
     65    /** CRC32 checksum. */
     66    RTDIGESTTYPE_CRC32,
     67    /** CRC64 checksum. */
    6868    RTDIGESTTYPE_CRC64,
    69     /** MD5 checksum (unsafe!) */
     69    /** MD5 checksum (unsafe!). */
    7070    RTDIGESTTYPE_MD5,
    71     /** SHA1 checksum (unsafe!) */
     71    /** SHA1 checksum (unsafe!). */
    7272    RTDIGESTTYPE_SHA1,
    73     /** SHA256 checksum */
     73    /** SHA256 checksum. */
    7474    RTDIGESTTYPE_SHA256,
    75     /** SHA512 checksum */
    76     RTDIGESTTYPE_SHA512
     75    /** SHA512 checksum. */
     76    RTDIGESTTYPE_SHA512,
     77    /** Usual 32-bit type blowup. */
     78    RTDIGESTTYPE_32BIT_HACK = 0x7fffffff
    7779} RTDIGESTTYPE;
    7880/** @} */
     
    448450 *                               VERR_MANIFEST_DIGEST_MISMATCH error case
    449451 *                               (optional).
     452 * @deprecated Use the RTMANIFEST based API instead.
    450453 */
    451454RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
     
    465468 * @param   pfnProgressCallback  optional callback for the progress indication
    466469 * @param   pvUser               user defined pointer for the callback
     470 * @deprecated Use the RTMANIFEST based API instead.
    467471 */
    468472RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed,
     
    482486 * @param   pfnProgressCallback  optional callback for the progress indication
    483487 * @param   pvUser               user defined pointer for the callback
     488 * @deprecated Use the RTMANIFEST based API instead.
    484489 */
    485490RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, RTDIGESTTYPE enmDigestType,
     
    488493
    489494/**
    490  * Verify the type of digest in the manifest file in memory.
     495 * Queries the first digest type found in the given manifest.
    491496 *
    492497 * @returns iprt status code.
     
    494499 * @param   pvBuf                Pointer to memory buffer of the manifest file.
    495500 * @param   cbSize               Size of the memory buffer.
    496  *                               VERR_MANIFEST_DIGEST_MISMATCH error case
    497  *                               (optional).
    498  * @param   digestType           digest type
    499  */
    500 RTR3DECL(int) RTManifestVerifyDigestType(void *pvBuf, size_t cbSize, RTDIGESTTYPE &digestType);
     501 * @param   penmDigestType       Where to return the first digest type found in
     502 *                               the manifest.
     503 * @deprecated Use the RTMANIFEST based API instead.
     504 */
     505RTR3DECL(int) RTManifestVerifyDigestType(void const *pvBuf, size_t cbSize, RTDIGESTTYPE *penmDigestType);
    501506
    502507/**
     
    513518 *                               VERR_MANIFEST_DIGEST_MISMATCH error case
    514519 *                               (optional).
     520 * @deprecated Use the RTMANIFEST based API instead.
    515521 */
    516522RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
     
    528534 * @param   paFiles              Array of file names and digests.
    529535 * @param   cFiles               Number of entries in paFiles.
     536 * @deprecated Use the RTMANIFEST based API instead.
    530537 */
    531538RTR3DECL(int) RTManifestWriteFilesBuf(void **ppvBuf, size_t *pcbSize, RTDIGESTTYPE enmDigestType, PRTMANIFESTTEST paFiles, size_t cFiles);
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r46972 r46980  
    965965                    uint64_t maxFileSize = _1M;
    966966                    size_t cbRead = 0;
    967                     void  *pBuf;
     967                    void  *pBuf; /** @todo r=bird: You leak this buffer! throwing stuff is evil. */
    968968
    969969                    vrc = RTFileGetSize(pFile, &cbFile);
     
    993993                    RTFileClose(pFile);
    994994
    995                     RTDIGESTTYPE digestType = RTDIGESTTYPE_UNKNOWN;
    996                     vrc = RTManifestVerifyDigestType(pBuf, cbRead, digestType);
     995                    RTDIGESTTYPE digestType;
     996                    vrc = RTManifestVerifyDigestType(pBuf, cbRead, &digestType);
    997997
    998998                    if (RT_FAILURE(vrc))
  • trunk/src/VBox/Runtime/common/checksum/manifest.cpp

    r46972 r46980  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Manifest file handling.
     3 * IPRT - Manifest file handling, old style - deprecated.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2012 Oracle Corporation
     7 * Copyright (C) 2009-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6767typedef RTMANIFESTCALLBACKDATA* PRTMANIFESTCALLBACKDATA;
    6868
     69
    6970/*******************************************************************************
    7071*   Private functions
     
    9697                                      pData->pvUser);
    9798}
     99
    98100
    99101/*******************************************************************************
     
    269271
    270272
    271 RTR3DECL(int) RTManifestVerifyDigestType(void *pvBuf, size_t cbSize, RTDIGESTTYPE &digestType)
     273RTR3DECL(int) RTManifestVerifyDigestType(void *pvBuf, size_t cbSize, RTDIGESTTYPE *penmDigestType)
    272274{
    273275    /* Validate input */
    274276    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
    275277    AssertReturn(cbSize > 0, VERR_INVALID_PARAMETER);
     278    AssertPtrRetrn(penmDigestType, VERR_INVALID_POINTER)
    276279
    277280    int rc = VINF_SUCCESS;
    278281
    279     char *pcBuf = (char*)pvBuf;
     282    char const *pcBuf = (char *)pvBuf;
    280283    size_t cbRead = 0;
    281284    /* Parse the manifest file line by line */
     
    283286    {
    284287        if (cbRead >= cbSize)
    285         {
    286             digestType = RTDIGESTTYPE_UNKNOWN;
    287             rc = VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE;
    288             break;
    289         }
     288            return VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE;
    290289
    291290        size_t cch = rtManifestIndexOfCharInBuf(pcBuf, cbSize - cbRead, '\n') + 1;
     
    303302        }
    304303
     304/** @todo r=bird: Missing space check here. */
    305305        /* Check for the digest algorithm */
    306         if (pcBuf[0] == 'S'
    307                  && pcBuf[1] == 'H'
    308                  && pcBuf[2] == 'A'
    309                  && pcBuf[3] == '1')
    310         {
    311             digestType = RTDIGESTTYPE_SHA1;
    312             break;
    313         }
    314         else if (pcBuf[0] == 'S'
    315                  && pcBuf[1] == 'H'
    316                  && pcBuf[2] == 'A'
    317                  && pcBuf[3] == '2'
    318                  && pcBuf[4] == '5'
    319                  && pcBuf[5] == '6')
    320         {
    321             digestType = RTDIGESTTYPE_SHA256;
     306        if (   pcBuf[0] == 'S'
     307            && pcBuf[1] == 'H'
     308            && pcBuf[2] == 'A'
     309            && pcBuf[3] == '1')
     310        {
     311            *penmDigestType = RTDIGESTTYPE_SHA1;
     312            break;
     313        }
     314        if (   pcBuf[0] == 'S'
     315            && pcBuf[1] == 'H'
     316            && pcBuf[2] == 'A'
     317            && pcBuf[3] == '2'
     318            && pcBuf[4] == '5'
     319            && pcBuf[5] == '6')
     320        {
     321            *penmDigestType = RTDIGESTTYPE_SHA256;
    322322            break;
    323323        }
     
    329329    return rc;
    330330}
     331
    331332
    332333RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed)
     
    373374        /** @todo r=bird:
    374375         *  -# Better deal with this EOF line platform dependency
    375          *  -# The SHA1 test should probably include a blank space check.
     376         *  -# The SHA1 and SHA256 tests should probably include a blank space check.
    376377         *  -# If there is a specific order to the elements in the string, it would be
    377378         *     good if the delimiter searching checked for it.
     
    380381
    381382        /* Check for the digest algorithm */
    382         if (   cch < 4  ||
    383                (!(   pcBuf[0] == 'S'
    384                  && pcBuf[1] == 'H'
    385                  && pcBuf[2] == 'A'
    386                  && pcBuf[3] == '1')
    387                         &&
    388                !(   pcBuf[0] == 'S'
    389                  && pcBuf[1] == 'H'
    390                  && pcBuf[2] == 'A'
    391                  && pcBuf[3] == '2'
    392                  && pcBuf[4] == '5'
    393                  && pcBuf[5] == '6'))
     383        if (   cch < 4 
     384            || (   !(   pcBuf[0] == 'S'
     385                     && pcBuf[1] == 'H'
     386                     && pcBuf[2] == 'A'
     387                     && pcBuf[3] == '1')
     388                &&
     389                   !(   pcBuf[0] == 'S'
     390                     && pcBuf[1] == 'H'
     391                     && pcBuf[2] == 'A'
     392                     && pcBuf[3] == '2'
     393                     && pcBuf[4] == '5'
     394                     && pcBuf[5] == '6')
    394395               )
     396            )
    395397        {
    396398            /* Digest unsupported */
     
    455457        for (size_t i = 0; i < cTests; ++i)
    456458        {
     459            /** @todo r=bird: Using RTStrStr here looks bogus. */
    457460            if (RTStrStr(paFiles[i].pTestPattern->pszTestFile, RTStrStrip(pszName)) != NULL)
    458461            {
     
    578581}
    579582
     583
  • trunk/src/VBox/Runtime/common/zip/tar.cpp

    r46971 r46980  
    55
    66/*
    7  * Copyright (C) 2009-2012 Oracle Corporation
     7 * Copyright (C) 2009-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    336336    /* Fill the header record */
    337337//    RT_ZERO(pRecord); - done by the caller.
     338    /** @todo use RTStrCopy */
    338339    size_t cb = RTStrPrintf(pRecord->h.name,  sizeof(pRecord->h.name),  "%s", pszSrcName);
    339340    if (cb < strlen(pszSrcName))
     
    16691670            pInt->pFileCache = NULL;
    16701671        }
    1671         else/* Are we still direct behind that header? */
     1672        else/* Are we still directly behind that header? */
    16721673        {
    16731674            /* Yes, so the streaming can start. Just return the cached file
     
    16781679            if (pInt->pFileCache->linkflag == LF_DIR)
    16791680                return VINF_TAR_DIR_PATH;
    1680             else
    1681                 return VINF_SUCCESS;
     1681            return VINF_SUCCESS;
    16821682        }
    16831683
     
    17221722
    17231723            if (pFileInt->linkflag == LF_DIR)
    1724             {
    17251724                rc = VINF_TAR_DIR_PATH;
    1726             }
    17271725        }
    17281726    } while (0);
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