VirtualBox

Ignore:
Timestamp:
Jul 4, 2013 11:38:28 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86988
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.

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