VirtualBox

Changeset 35188 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Dec 16, 2010 3:13:07 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69027
Message:

Use RTERRINFO in SUPLib for hardening APIs and such.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMLdr.cpp

    r34286 r35188  
    295295         * Load the loader item.
    296296         */
    297         char szErr[4096+1024];
    298         rc = SUPR3HardenedLdrLoadPlugIn(pModule->szFilename, &pModule->hLdrMod, szErr, sizeof(szErr));
     297        RTERRINFOSTATIC ErrInfo;
     298        RTErrInfoInitStatic(&ErrInfo);
     299        rc = SUPR3HardenedLdrLoadPlugIn(pModule->szFilename, &pModule->hLdrMod, &ErrInfo.Core);
    299300        if (RT_SUCCESS(rc))
    300301        {
     
    306307            /* Something went wrong, most likely module not found. Don't consider other unlikely errors */
    307308            rc = VMSetError(pUVM->pVM, rc, RT_SRC_POS,
    308                             N_("Unable to load R3 module %s (%s): %s"), pModule->szFilename, pszName, szErr);
     309                            N_("Unable to load R3 module %s (%s): %s"), pModule->szFilename, pszName, ErrInfo.Core.pszMsg);
    309310            RTMemFree(pModule);
    310311        }
     
    483484     * Open the loader item.
    484485     */
    485     char szErr[4096+1024];
    486     int rc = SUPR3HardenedVerifyPlugIn(pszFilename, szErr, sizeof(szErr));
     486    RTERRINFOSTATIC ErrInfo;
     487    RTErrInfoInitStatic(&ErrInfo);
     488    int rc = SUPR3HardenedVerifyPlugIn(pszFilename, &ErrInfo.Core);
    487489    if (RT_SUCCESS(rc))
    488490    {
    489         szErr[0] = '\0';
     491        RTErrInfoClear(&ErrInfo.Core);
    490492        rc = RTLdrOpen(pszFilename, 0, RTLDRARCH_X86_32, &pModule->hLdrMod);
    491493    }
     
    565567
    566568    /* Don't consider VERR_PDM_MODULE_NAME_CLASH and VERR_NO_MEMORY above as these are very unlikely. */
    567     if (RT_FAILURE(rc) && szErr[0])
    568         rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s: %s"), pszFilename, szErr);
     569    if (RT_FAILURE(rc) && RTErrInfoIsSet(&ErrInfo.Core))
     570        rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s: %s"), pszFilename, ErrInfo.Core.pszMsg);
    569571    else if (RT_FAILURE(rc))
    570572        rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s"), pszFilename);
     
    633635     * Ask the support library to load it.
    634636     */
    635     char szErr[4096+1024];
    636     void *pvImageBase;
    637     int rc = SUPR3LoadModule(pszFilename, pszName, &pvImageBase, szErr, sizeof(szErr));
     637    void           *pvImageBase;
     638    RTERRINFOSTATIC ErrInfo;
     639    RTErrInfoInitStatic(&ErrInfo);
     640    int rc = SUPR3LoadModule(pszFilename, pszName, &pvImageBase, &ErrInfo.Core);
    638641    if (RT_SUCCESS(rc))
    639642    {
     
    662665    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    663666    RTMemFree(pModule);
    664     LogRel(("pdmR3LoadR0U: pszName=\"%s\" rc=%Rrc szErr=\"%s\"\n", pszName, rc, szErr));
     667    LogRel(("pdmR3LoadR0U: pszName=\"%s\" rc=%Rrc szErr=\"%s\"\n", pszName, rc, ErrInfo.Core.pszMsg));
    665668
    666669    /* Don't consider VERR_PDM_MODULE_NAME_CLASH and VERR_NO_MEMORY above as these are very unlikely. */
    667670    if (RT_FAILURE(rc) && pUVM->pVM) /** @todo VMR3SetErrorU. */
    668         rc = VMSetError(pUVM->pVM, rc, RT_SRC_POS, N_("Cannot load R0 module %s: %s"), pszFilename, szErr);
     671        rc = VMSetError(pUVM->pVM, rc, RT_SRC_POS, N_("Cannot load R0 module %s: %s"), pszFilename, ErrInfo.Core.pszMsg);
    669672
    670673    RTMemTmpFree(pszFile); /* might be reference thru pszFilename in the above VMSetError call. */
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