VirtualBox

Changeset 84141 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
May 4, 2020 9:15:30 PM (5 years ago)
Author:
vboxsync
Message:

Main/Appliance: There should be no need to store two copies of the manifest. Also, we must not return unsanitized strings thru the API. IFF there is genuine need for non-sanitized data, we must return it as a BYTE array rather than a unicode string. bugref:9699

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r84031 r84141  
    507507HRESULT Appliance::getManifest(com::Utf8Str &aManifest, com::Utf8Str &aManifestName)
    508508{
    509     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    510 
    511     aManifest = m->strManifest;
     509    /* Write lock the appliance here as we don't want concurrent hMemFileTheirManifest
     510       accesses (lazyness/paranoia). */
     511    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     512
     513    Assert(aManifest.isEmpty());
     514    if (m->hMemFileTheirManifest != NIL_RTVFSFILE)
     515    {
     516        uint64_t cchManifest = 0;
     517        int rc = RTVfsFileQuerySize(m->hMemFileTheirManifest, &cchManifest);
     518        AssertRCReturn(rc, setErrorVrc(rc));
     519
     520        rc = aManifest.reserveNoThrow(cchManifest + 1);
     521        AssertRCReturn(rc, setErrorVrc(rc));
     522
     523        char *pszManifest = aManifest.mutableRaw();
     524        rc = RTVfsFileReadAt(m->hMemFileTheirManifest, 0, pszManifest, cchManifest, NULL);
     525        pszManifest[cchManifest] = '\0';
     526        AssertRCReturn(rc, setErrorVrc(rc));
     527        RTStrPurgeEncoding(pszManifest);
     528        aManifest.jolt();
     529    }
     530
    512531    aManifestName = m->strManifestName;
    513532    return S_OK;
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r84031 r84141  
    25612561 *                              reference is always consumed.
    25622562 * @param   pszSubFileNm        The manifest filename (no path) for error
    2563  *                              messages and logging.
     2563 *                              messages, logging and strManifestName.
    25642564 * @returns COM status code, error info set.
    25652565 * @throws  Nothing
     
    25702570
    25712571    /* Remember the manifet file name */
    2572     m->strManifestName.assign(pszSubFileNm);
     2572    HRESULT hrc = m->strManifestName.assignEx(pszSubFileNm);
     2573    AssertReturn(SUCCEEDED(hrc), hrc);
    25732574
    25742575    /*
     
    25832584
    25842585    /*
    2585      * Store the manifest as a string in the m->strManifest
    2586      */
    2587     {
    2588         char   abBuf[_16K];
    2589         size_t cbRead;
    2590 
    2591         vrc = RTVfsFileRead(m->hMemFileTheirManifest, &abBuf, sizeof(abBuf), &cbRead);
    2592         if (RT_SUCCESS(vrc))
    2593             m->strManifest.assignEx((const char*)abBuf, cbRead);
    2594 
    2595         /* Rewind to the beginning, because the manifest will be read later again */
    2596         RTVfsFileSeek(m->hMemFileTheirManifest, 0, RTFILE_SEEK_BEGIN, NULL);
    2597     }
    2598 
    2599     /*
    26002586     * Parse the manifest.
    26012587     */
     
    26092595    RTVfsIoStrmRelease(hVfsIos);
    26102596    if (RT_FAILURE(vrc))
    2611         throw setErrorVrc(vrc, tr("Failed to parse manifest file '%s' for '%s' (%Rrc): %s"),
    2612                           pszSubFileNm, pTask->locInfo.strPath.c_str(), vrc, szErr);
     2597        return setErrorVrc(vrc, tr("Failed to parse manifest file '%s' for '%s' (%Rrc): %s"),
     2598                           pszSubFileNm, pTask->locInfo.strPath.c_str(), vrc, szErr);
    26132599
    26142600    /*
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