VirtualBox

Changeset 35188 in vbox for trunk/src/VBox


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.

Location:
trunk/src/VBox
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r35172 r35188  
    835835        if (fFFMPEG)
    836836        {
    837             HRESULT rcc = S_OK;
    838             int     rrc = VINF_SUCCESS;
    839             char    szErr[8192];
     837            HRESULT         rcc = S_OK;
     838            int             rrc = VINF_SUCCESS;
     839            RTERRINFOSTATIC ErrInfo;
    840840
    841841            Log2(("VBoxHeadless: loading VBoxFFmpegFB shared library\n"));
    842             rrc = SUPR3HardenedLdrLoadAppPriv("VBoxFFmpegFB", &hLdrFFmpegFB, 0 /*=fFlags*/, szErr, sizeof(szErr));
     842            RTErrInfoInitStatic(&ErrInfo);
     843            rrc = SUPR3HardenedLdrLoadAppPriv("VBoxFFmpegFB", &hLdrFFmpegFB, 0 /*fFlags*/, &ErrInfo.Core);
    843844
    844845            if (RT_SUCCESS(rrc))
     
    861862                             "you wish to use is supported on your system\n", rcc);
    862863            }
    863             if (RT_SUCCESS(rrc) && (rcc == S_OK))
     864            if (RT_SUCCESS(rrc) && rcc == S_OK)
    864865            {
    865866                Log2(("VBoxHeadless: Registering framebuffer\n"));
     
    867868                display->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, pFramebuffer);
    868869            }
    869             if (!RT_SUCCESS(rrc) || (rcc != S_OK))
     870            if (!RT_SUCCESS(rrc) || rcc != S_OK)
    870871                rc = E_FAIL;
    871872        }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r35152 r35188  
    51135113    if (mDbgEnabled)
    51145114    {
    5115         char szErr[8192];
    5116         szErr[0] = '\0';
    5117         int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &mhVBoxDbg, 0 /*=fFlags*/, szErr, sizeof(szErr));
     5115        RTERRINFOSTATIC ErrInfo;
     5116        RTErrInfoInitStatic(&ErrInfo);
     5117        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &mhVBoxDbg, 0 /*fFlags*/, &ErrInfo.Core);
    51185118        if (RT_FAILURE(vrc))
    51195119        {
    51205120            mhVBoxDbg = NIL_RTLDRMOD;
    51215121            mDbgAutoShow =  mDbgAutoShowCommandLine = mDbgAutoShowStatistics = false;
    5122             LogRel(("Failed to load VBoxDbg, rc=%Rrc - %s\n", vrc, szErr));
     5122            LogRel(("Failed to load VBoxDbg, rc=%Rrc - %s\n", vrc, ErrInfo.Core.pszMsg));
    51235123        }
    51245124    }
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r35183 r35188  
    14381438
    14391439
    1440 SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, char *pszErr, size_t cbErr)
     1440SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, PRTERRINFO pErrInfo)
    14411441{
    14421442    /*
     
    14441444     */
    14451445    AssertPtr(pszArgv0);
    1446     AssertPtr(pszErr);
    1447     Assert(cbErr > 32);
     1446    RTErrInfoClear(pErrInfo);
    14481447
    14491448    /*
     
    14521451    char szExecPath[RTPATH_MAX];
    14531452    if (!RTProcGetExecutablePath(szExecPath, sizeof(szExecPath)))
    1454     {
    1455         RTStrPrintf(pszErr, cbErr, "RTProcGetExecutablePath failed");
    1456         return VERR_INTERNAL_ERROR_2;
    1457     }
     1453        return RTErrInfoSet(pErrInfo, VERR_INTERNAL_ERROR_2, "RTProcGetExecutablePath failed");
    14581454
    14591455    int rc;
     
    14651461         */
    14661462        if (RTPathCompare(pszArgv0, szExecPath) != 0)
    1467         {
    1468             RTStrPrintf(pszErr, cbErr, "argv[0] does not match the executable image path: '%s' != '%s'", pszArgv0, szExecPath);
    1469             return VERR_SUPLIB_INVALID_ARGV0_INTERNAL;
    1470         }
     1463            return RTErrInfoSetF(pErrInfo, VERR_SUPLIB_INVALID_ARGV0_INTERNAL,
     1464                                 "argv[0] does not match the executable image path: '%s' != '%s'", pszArgv0, szExecPath);
    14711465
    14721466        /*
     
    14771471        rc = RTPathAppPrivateArch(szAppPrivateArch, sizeof(szAppPrivateArch));
    14781472        if (RT_FAILURE(rc))
    1479         {
    1480             RTStrPrintf(pszErr, cbErr, "RTPathAppPrivateArch failed with rc=%Rrc", rc);
    1481             return VERR_SUPLIB_INVALID_ARGV0_INTERNAL;
    1482         }
     1473            return RTErrInfoSetF(pErrInfo, VERR_SUPLIB_INVALID_ARGV0_INTERNAL,
     1474                                 "RTPathAppPrivateArch failed with rc=%Rrc", rc);
    14831475        size_t cchAppPrivateArch = strlen(szAppPrivateArch);
    14841476        if (   cchAppPrivateArch >= strlen(szExecPath)
    14851477            || !RTPATH_IS_SLASH(szExecPath[cchAppPrivateArch]))
    1486         {
    1487             RTStrPrintf(pszErr, cbErr, "Internal executable does reside under RTPathAppPrivateArch");
    1488             return VERR_SUPLIB_INVALID_INTERNAL_APP_DIR;
    1489         }
     1478            return RTErrInfoSet(pErrInfo, VERR_SUPLIB_INVALID_INTERNAL_APP_DIR,
     1479                                "Internal executable does reside under RTPathAppPrivateArch");
    14901480        szExecPath[cchAppPrivateArch] = '\0';
    14911481        if (RTPathCompare(szExecPath, szAppPrivateArch) != 0)
    1492         {
    1493             RTStrPrintf(pszErr, cbErr, "Internal executable does reside under RTPathAppPrivateArch");
    1494             return VERR_SUPLIB_INVALID_INTERNAL_APP_DIR;
    1495         }
     1482            return RTErrInfoSet(pErrInfo, VERR_SUPLIB_INVALID_INTERNAL_APP_DIR,
     1483                                "Internal executable does reside under RTPathAppPrivateArch");
    14961484        szExecPath[cchAppPrivateArch] = RTPATH_SLASH;
    14971485    }
     
    15011489     * Verify that the image file and parent directories are sane.
    15021490     */
    1503     rc = supR3HardenedVerifyFile(szExecPath, RTHCUINTPTR_MAX, pszErr, cbErr);
     1491    rc = supR3HardenedVerifyFile(szExecPath, RTHCUINTPTR_MAX, pErrInfo);
    15041492    if (RT_FAILURE(rc))
    15051493        return rc;
     
    15101498
    15111499
    1512 SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr)
     1500SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo)
    15131501{
    15141502    /*
     
    15161504     */
    15171505    AssertPtr(pszDirPath);
    1518     AssertPtr(pszErr);
    1519     Assert(cbErr > 32);
     1506    RTErrInfoClear(pErrInfo);
    15201507
    15211508    /*
     
    15231510     */
    15241511#ifdef VBOX_WITH_HARDENING
    1525     int rc = supR3HardenedVerifyDir(pszDirPath, fRecursive, fCheckFiles, pszErr, cbErr);
    1526     if (RT_FAILURE(rc) && (!pszErr || !cbErr))
     1512    int rc = supR3HardenedVerifyDir(pszDirPath, fRecursive, fCheckFiles, pErrInfo);
     1513    if (RT_FAILURE(rc) && !RTErrInfoIsSet(pErrInfo))
    15271514        LogRel(("supR3HardenedVerifyDir: Verification of \"%s\" failed, rc=%Rrc\n", pszDirPath, rc));
    15281515    return rc;
     
    15331520
    15341521
    1535 SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, char *pszErr, size_t cbErr)
     1522SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, PRTERRINFO pErrInfo)
    15361523{
    15371524    /*
     
    15391526     */
    15401527    AssertPtr(pszFilename);
    1541     AssertPtr(pszErr);
    1542     Assert(cbErr > 32);
     1528    RTErrInfoClear(pErrInfo);
    15431529
    15441530    /*
     
    15461532     */
    15471533#ifdef VBOX_WITH_HARDENING
    1548     int rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX,  pszErr, cbErr);
    1549     if (RT_FAILURE(rc) && (!pszErr || !cbErr))
     1534    int rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pErrInfo);
     1535    if (RT_FAILURE(rc) && !RTErrInfoIsSet(pErrInfo))
    15501536        LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc));
    15511537    return rc;
     
    15561542
    15571543
    1558 SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, char *pszErr, size_t cbErr)
     1544SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo)
    15591545{
    15601546    /*
    15611547     * Check that the module can be trusted.
    15621548     */
    1563     int rc = SUPR3HardenedVerifyPlugIn(pszFilename, pszErr, cbErr);
     1549    int rc = SUPR3HardenedVerifyPlugIn(pszFilename, pErrInfo);
    15641550    if (RT_SUCCESS(rc))
    15651551    {
    15661552        rc = supLoadModule(pszFilename, pszModule, NULL, ppvImageBase);
    15671553        if (RT_FAILURE(rc))
    1568             RTStrPrintf(pszErr, cbErr, "supLoadModule returned %Rrc", rc);
     1554            RTErrInfoSetF(pErrInfo, rc, "supLoadModule returned %Rrc", rc);
    15691555    }
    15701556    return rc;
     
    20552041{
    20562042    void *pvImageBase;
    2057     return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL, 0);
     2043    return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL /*pErrInfo*/);
    20582044}
    20592045
     
    20842070 * @param   phLdrMod        Where to store the handle to the loaded module.
    20852071 * @param   fFlags          See RTLDFLAGS_.
    2086  * @param   pszError        Where to return the loader error. Optional.
    2087  * @param   cbError         The size of the buffer pointed to by @a pszError.
     2072 * @param   pErrInfo        Where to return extended error information.
     2073 *                          Optional.
     2074 *
    20882075 */
    2089 static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
     2076static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
    20902077{
    20912078#ifdef VBOX_WITH_HARDENING
     
    20972084    {
    20982085        LogRel(("supR3HardenedLdrLoadIt: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc));
    2099         return rc;
     2086        return RTErrInfoSet(pErrInfo, rc, "supR3HardenedVerifyFixedFile failed");
    21002087    }
    21012088#endif
     
    21042091     * Try load it.
    21052092     */
    2106     RTERRINFO  ErrInfo;
    2107     PRTERRINFO pErrInfo;
    2108     if (!pszError || !cbError)
    2109         pErrInfo = NULL;
    2110     else
    2111         pErrInfo = RTErrInfoInit(&ErrInfo, pszError, cbError);
    21122093    return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, pErrInfo);
    21132094}
    21142095
    21152096
    2116 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
     2097SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
    21172098{
    21182099    /*
    21192100     * Validate input.
    21202101     */
    2121     if (!pszError)
    2122         AssertReturn(!cbError, VERR_INVALID_PARAMETER);
    2123     else
    2124     {
    2125         AssertPtrReturn(pszError, VERR_INVALID_POINTER);
    2126         if (cbError)
    2127             *pszError = '\0';
    2128         else
    2129             pszError = NULL;
    2130     }
     2102    RTErrInfoClear(pErrInfo);
    21312103    AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
    21322104    AssertPtrReturn(phLdrMod, VERR_INVALID_POINTER);
     
    21522124     * Pass it on to the common library loader.
    21532125     */
    2154     return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, pszError, cbError);
    2155 }
    2156 
    2157 
    2158 SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
    2159 {
    2160     LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));
     2126    return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, pErrInfo);
     2127}
     2128
     2129
     2130SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
     2131{
     2132    LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pErrInfo=%p\n", pszFilename, pszFilename, phLdrMod, fFlags, pErrInfo));
    21612133
    21622134    /*
    21632135     * Validate input.
    21642136     */
    2165     if (!pszError)
    2166         AssertReturn(!cbError, VERR_INVALID_PARAMETER);
    2167     else
    2168     {
    2169         AssertPtrReturn(pszError, VERR_INVALID_POINTER);
    2170         if (cbError)
    2171             *pszError = '\0';
    2172         else
    2173             pszError = NULL;
    2174     }
     2137    RTErrInfoClear(pErrInfo);
    21752138    AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER);
    21762139    *phLdrMod = NIL_RTLDRMOD;
     
    22142177     * Pass it on to SUPR3HardenedLdrLoad.
    22152178     */
    2216     rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, pszError, cbError);
     2179    rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, pErrInfo);
    22172180
    22182181    LogFlow(("SUPR3HardenedLdrLoadAppPriv: returns %Rrc\n", rc));
     
    22212184
    22222185
    2223 SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszErr, size_t cbErr)
     2186SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
    22242187{
    22252188    int rc;
     
    22282191     * Validate input.
    22292192     */
    2230     AssertPtr(pszErr);
    2231     Assert(cbErr > 32);
     2193    RTErrInfoClear(pErrInfo);
    22322194    AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER);
    22332195    *phLdrMod = NIL_RTLDRMOD;
     
    22392201     * Verify the image file.
    22402202     */
    2241     rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pszErr, cbErr);
     2203    rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pErrInfo);
    22422204    if (RT_FAILURE(rc))
    22432205    {
    2244         if (!pszErr || !cbErr)
     2206        if (!RTErrInfoIsSet(pErrInfo))
    22452207            LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc));
    22462208        return rc;
     
    22512213     * Try load it.
    22522214     */
    2253     RTERRINFO  ErrInfo;
    2254     PRTERRINFO pErrInfo;
    2255     if (!pszErr || !cbErr)
    2256         pErrInfo = NULL;
    2257     else
    2258         pErrInfo = RTErrInfoInit(&ErrInfo, pszErr, cbErr);
    22592215    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*fFlags*/, pErrInfo);
    22602216}
  • trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h

    r33741 r35188  
    320320DECLHIDDEN(int)     supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal);
    321321DECLHIDDEN(int)     supR3HardenedVerifyFixedFile(const char *pszFilename, bool fFatal);
    322 DECLHIDDEN(int)     supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr);
    323 DECLHIDDEN(int)     supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, char *pszErr, size_t cbErr);
     322DECLHIDDEN(int)     supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
     323DECLHIDDEN(int)     supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, PRTERRINFO pErrInfo);
    324324DECLHIDDEN(void)    supR3HardenedGetPreInitData(PSUPPREINITDATA pPreInitData);
    325325DECLHIDDEN(int)     supR3HardenedRecvPreInitData(PCSUPPREINITDATA pPreInitData);
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp

    r34563 r35188  
    764764 * @returns Returns @a rc
    765765 * @param   rc                  The return code.
    766  * @param   pszErr              The error buffer.
    767  * @param   cbErr               The size of the error buffer.
     766 * @param   pErrInfo            The error info structure.
    768767 * @param   cMsgs               The number of messages in the ellipsis.
    769768 * @param   ...                 Message parts.
    770769 */
    771 static int supR3HardenedSetErrorN(int rc, char *pszErr, size_t cbErr, unsigned cMsgs, ...)
    772 {
    773     va_list va;
    774     va_start(va, cMsgs);
    775     while (cMsgs-- > 0 && cbErr > 0)
    776     {
    777         const char *pszMsg = va_arg(va,  const char *);
    778         size_t cchMsg = VALID_PTR(pszMsg) ? strlen(pszMsg) : 0;
    779         if (cchMsg >= cbErr)
    780             cchMsg = cbErr - 1;
    781         memcpy(pszErr, pszMsg, cchMsg);
    782         pszErr[cchMsg] = '\0';
    783         pszErr += cchMsg;
    784         cbErr -= cchMsg;
    785     }
    786     va_end(va);
     770static int supR3HardenedSetErrorN(int rc, PRTERRINFO pErrInfo, unsigned cMsgs, ...)
     771{
     772    if (pErrInfo)
     773    {
     774        size_t cbErr  = pErrInfo->cbMsg;
     775        char  *pszErr = pErrInfo->pszMsg;
     776
     777        va_list va;
     778        va_start(va, cMsgs);
     779        while (cMsgs-- > 0 && cbErr > 0)
     780        {
     781            const char *pszMsg = va_arg(va,  const char *);
     782            size_t cchMsg = VALID_PTR(pszMsg) ? strlen(pszMsg) : 0;
     783            if (cchMsg >= cbErr)
     784                cchMsg = cbErr - 1;
     785            memcpy(pszErr, pszMsg, cchMsg);
     786            pszErr[cchMsg] = '\0';
     787            pszErr += cchMsg;
     788            cbErr -= cchMsg;
     789        }
     790        va_end(va);
     791
     792        pErrInfo->rc      = rc;
     793        pErrInfo->fFlags |= RTERRINFO_FLAGS_SET;
     794    }
    787795
    788796    return rc;
     
    795803 * @returns Returns @a rc
    796804 * @param   rc                  The return code.
    797  * @param   pszErr              The error buffer.
    798  * @param   cbErr               The size of the error buffer.
     805 * @param   pErrInfo            The error info structure.
    799806 * @param   pszMsg1             The first message part.
    800807 * @param   pszMsg2             The second message part.
    801808 * @param   pszMsg3             The third message part.
    802809 */
    803 static int supR3HardenedSetError3(int rc, char *pszErr, size_t cbErr, const char *pszMsg1,
     810static int supR3HardenedSetError3(int rc, PRTERRINFO pErrInfo, const char *pszMsg1,
    804811                                  const char *pszMsg2, const char *pszMsg3)
    805812{
    806     return supR3HardenedSetErrorN(rc, pszErr, cbErr, 3, pszMsg1, pszMsg2, pszMsg3);
     813    return supR3HardenedSetErrorN(rc, pErrInfo, 3, pszMsg1, pszMsg2, pszMsg3);
    807814}
    808815
     
    813820 * @returns Returns @a rc
    814821 * @param   rc                  The return code.
    815  * @param   pszErr              The error buffer.
    816  * @param   cbErr               The size of the error buffer.
     822 * @param   pErrInfo            The error info structure.
    817823 * @param   pszMsg1             The first message part.
    818824 * @param   pszMsg2             The second message part.
    819825 */
    820 static int supR3HardenedSetError2(int rc, char *pszErr, size_t cbErr, const char *pszMsg1,
     826static int supR3HardenedSetError2(int rc, PRTERRINFO pErrInfo, const char *pszMsg1,
    821827                                  const char *pszMsg2)
    822828{
    823     return supR3HardenedSetErrorN(rc, pszErr, cbErr, 2, pszMsg1, pszMsg2);
     829    return supR3HardenedSetErrorN(rc, pErrInfo, 2, pszMsg1, pszMsg2);
    824830}
    825831
     
    830836 * @returns Returns @a rc
    831837 * @param   rc                  The return code.
    832  * @param   pszErr              The error buffer.
    833  * @param   cbErr               The size of the error buffer.
     838 * @param   pErrInfo            The error info structure.
    834839 * @param   pszMsg              The message.
    835840 */
    836 static int supR3HardenedSetError(int rc, char *pszErr, size_t cbErr, const char *pszMsg)
    837 {
    838     return supR3HardenedSetErrorN(rc, pszErr, cbErr, 1, pszMsg);
     841static int supR3HardenedSetError(int rc, PRTERRINFO pErrInfo, const char *pszMsg)
     842{
     843    return supR3HardenedSetErrorN(rc, pErrInfo, 1, pszMsg);
    839844}
    840845
     
    877882 * @returns VBox status code.
    878883 * @param   pszPath             The path to check.
    879  * @param   pszErr              The error buffer.
    880  * @param   cbErr               The size of the error buffer.
     884 * @param   pErrInfo            The error info structure.
    881885 * @param   pInfo               Where to return a copy of the path along with
    882886 *                              parsing information.
    883887 */
    884 static int supR3HardenedVerifyPathSanity(const char *pszPath, char *pszErr, size_t cbErr, PSUPR3HARDENEDPATHINFO pInfo)
     888static int supR3HardenedVerifyPathSanity(const char *pszPath, PRTERRINFO pErrInfo, PSUPR3HARDENEDPATHINFO pInfo)
    885889{
    886890    const char *pszSrc = pszPath;
     
    894898        || pszSrc[1] != ':'
    895899        || !RTPATH_IS_SLASH(pszSrc[2]))
    896         return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pszErr, cbErr, "The path is not absolute: '", pszPath, "'");
     900        return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, "The path is not absolute: '", pszPath, "'");
    897901
    898902    *pszDst++ = RT_C_TO_UPPER(pszSrc[0]);
     
    903907#else
    904908    if (!RTPATH_IS_SLASH(pszSrc[0]))
    905         return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pszErr, cbErr, "The path is not absolute: '", pszPath, "'");
     909        return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, "The path is not absolute: '", pszPath, "'");
    906910
    907911    *pszDst++ = RTPATH_SLASH;
     
    914918     */
    915919    if (pszSrc[0] == '\0')
    916         return supR3HardenedSetError3(VERR_SUPLIB_PATH_IS_ROOT, pszErr, cbErr, "The path is root: '", pszPath, "'");
     920        return supR3HardenedSetError3(VERR_SUPLIB_PATH_IS_ROOT, pErrInfo, "The path is root: '", pszPath, "'");
    917921    if (   pszSrc[1] == '\0'
    918922        || pszSrc[2] == '\0')
    919         return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_SHORT, pszErr, cbErr, "The path is too short: '", pszPath, "'");
     923        return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_SHORT, pErrInfo, "The path is too short: '", pszPath, "'");
    920924
    921925    /*
     
    928932        /* Sanity checks. */
    929933        if (RTPATH_IS_SLASH(pszSrc[0])) /* can be relaxed if we care. */
    930             return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_CLEAN, pszErr, cbErr,
     934            return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_CLEAN, pErrInfo,
    931935                                          "The path is not clean of double slashes: '", pszPath, "'");
    932936        if (   pszSrc[0] == '.'
    933937            && pszSrc[1] == '.'
    934938            && RTPATH_IS_SLASH(pszSrc[2]))
    935             return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pszErr, cbErr,
     939            return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo,
    936940                                          "The path is not absolute: '", pszPath, "'");
    937941
    938942        /* Record the start of the component. */
    939943        if (pInfo->cComponents >= RT_ELEMENTS(pInfo->aoffComponents) - 1)
    940             return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_MANY_COMPONENTS, pszErr, cbErr,
     944            return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_MANY_COMPONENTS, pErrInfo,
    941945                                          "The path has too many components: '", pszPath, "'");
    942946        pInfo->aoffComponents[pInfo->cComponents++] = pszDst - &pInfo->szPath[0];
     
    956960            *pszDst++ = *pszSrc++;
    957961            if ((uintptr_t)(pszDst - &pInfo->szPath[0]) >= SUPR3HARDENED_MAX_PATH)
    958                 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_LONG, pszErr, cbErr,
     962                return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_LONG, pErrInfo,
    959963                                              "The path is too long: '", pszPath, "'");
    960964        }
     
    10001004 * @param   pszPath             The path to the object.
    10011005 * @param   pFsObjState         Where to return the state information.
    1002  * @param   pszErr              The error buffer.
    1003  * @param   cbErr               The size of the error buffer.
    1004  */
    1005 static int supR3HardenedQueryFsObjectByPath(char const *pszPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState,
    1006                                             char *pszErr, size_t cbErr)
     1006 * @param   pErrInfo            The error info structure.
     1007 */
     1008static int supR3HardenedQueryFsObjectByPath(char const *pszPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState, PRTERRINFO pErrInfo)
    10071009{
    10081010#if defined(RT_OS_WINDOWS)
     
    10191021        /* Ignore access errors */
    10201022        if (errno != EACCES)
    1021             return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pszErr, cbErr,
     1023            return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pErrInfo,
    10221024                                          5, "stat failed with ", strerror(errno), " on: '", pszPath, "'");
    10231025    }
     
    10431045 * @param   pszPath             The path to the object. (For the error message
    10441046 *                              only.)
    1045  * @param   pszErr              The error buffer.
    1046  * @param   cbErr               The size of the error buffer.
     1047 * @param   pErrInfo            The error info structure.
    10471048 */
    10481049static int supR3HardenedQueryFsObjectByHandle(RTHCUINTPTR hNative, PSUPR3HARDENEDFSOBJSTATE pFsObjState,
    1049                                               char const *pszPath, char *pszErr, size_t cbErr)
     1050                                              char const *pszPath, PRTERRINFO pErrInfo)
    10501051{
    10511052#if defined(RT_OS_WINDOWS)
     
    10591060     */
    10601061    if (fstat((int)hNative, &pFsObjState->Stat) != 0)
    1061         return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pszErr, cbErr,
     1062        return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pErrInfo,
    10621063                                      5, "fstat failed with ", strerror(errno), " on '", pszPath, "'");
    10631064
     
    10811082 * @param   pszPath             The path to the object @a pFsObjState
    10821083 *                              describes.  (For the error message.)
    1083  * @param   pszErr              The error buffer.
    1084  * @param   cbErr               The size of the error buffer.
     1084 * @param   pErrInfo            The error info structure.
    10851085 */
    10861086static int supR3HardenedIsSameFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState1, PCSUPR3HARDENEDFSOBJSTATE pFsObjState2,
    1087                                        const char *pszPath, char *pszErr, size_t cbErr)
     1087                                       const char *pszPath, PRTERRINFO pErrInfo)
    10881088{
    10891089#if defined(RT_OS_WINDOWS)
     
    11011101    if (   pFsObjState1->Stat.st_ino != pFsObjState2->Stat.st_ino
    11021102        || pFsObjState1->Stat.st_dev != pFsObjState2->Stat.st_dev)
    1103         return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pszErr, cbErr,
     1103        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo,
    11041104                                      "The native handle is not the same as '", pszPath, "' (ino/dev)");
    11051105    if (   pFsObjState1->Stat.st_uid != pFsObjState2->Stat.st_uid
    11061106        || pFsObjState1->Stat.st_gid != pFsObjState2->Stat.st_gid)
    1107         return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pszErr, cbErr,
     1107        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo,
    11081108                                      "The native handle is not the same as '", pszPath, "' (uid/gid)");
    11091109    if (   (pFsObjState1->Stat.st_mode & (S_IFMT | S_IWUSR | S_IWGRP | S_IWOTH))
    11101110        != (pFsObjState2->Stat.st_mode & (S_IFMT | S_IWUSR | S_IWGRP | S_IWOTH)))
    1111         return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pszErr, cbErr,
     1111        return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo,
    11121112                                      "The native handle is not the same as '", pszPath, "' (mode)");
    11131113    return VINF_SUCCESS;
     
    11281128 * @param   pszPath             The path to the object. (For error messages
    11291129 *                              only.)
    1130  * @param   pszErr              The error buffer.
    1131  * @param   cbErr               The size of the error buffer.
     1130 * @param   pErrInfo            The error info structure.
    11321131 */
    11331132static int supR3HardenedVerifyFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState, bool fDir, bool fRelaxed,
    1134                                        const char *pszPath, char *pszErr, size_t cbErr)
     1133                                       const char *pszPath, PRTERRINFO pErrInfo)
    11351134{
    11361135#if defined(RT_OS_WINDOWS)
     
    11491148     */
    11501149    if (pFsObjState->Stat.st_uid != 0)
    1151         return supR3HardenedSetError3(VERR_SUPLIB_OWNER_NOT_ROOT, pszErr, cbErr, "The owner is not root: '", pszPath, "'");
     1150        return supR3HardenedSetError3(VERR_SUPLIB_OWNER_NOT_ROOT, pErrInfo, "The owner is not root: '", pszPath, "'");
    11521151
    11531152    /*
     
    11671166        if (pFsObjState->Stat.st_gid != 80 /*admin*/) /** @todo dynamically resolve the admin group? */
    11681167#endif
    1169             return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pszErr, cbErr,
     1168            return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pErrInfo,
    11701169                                          "The group is not a system group and it has write access to '", pszPath, "'");
    11711170    }
     
    11751174     */
    11761175    if (pFsObjState->Stat.st_mode & S_IWOTH)
    1177         return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pszErr, cbErr,
     1176        return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pErrInfo,
    11781177                                      "World writable: '", pszPath, "'");
    11791178
     
    11901189    {
    11911190        if (S_ISLNK(pFsObjState->Stat.st_mode))
    1192             return supR3HardenedSetError3(VERR_SUPLIB_SYMLINKS_ARE_NOT_PERMITTED, pszErr, cbErr,
     1191            return supR3HardenedSetError3(VERR_SUPLIB_SYMLINKS_ARE_NOT_PERMITTED, pErrInfo,
    11931192                                          "Symlinks are not permitted: '", pszPath, "'");
    1194         return supR3HardenedSetError3(VERR_SUPLIB_NOT_DIR_NOT_FILE, pszErr, cbErr,
     1193        return supR3HardenedSetError3(VERR_SUPLIB_NOT_DIR_NOT_FILE, pErrInfo,
    11951194                                      "Not regular file or directory: '", pszPath, "'");
    11961195    }
     
    11981197    {
    11991198        if (S_ISDIR(pFsObjState->Stat.st_mode))
    1200             return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pszErr, cbErr,
     1199            return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pErrInfo,
    12011200                                          "Expected file but found directory: '", pszPath, "'");
    1202         return supR3HardenedSetError3(VERR_SUPLIB_IS_FILE, pszErr, cbErr,
     1201        return supR3HardenedSetError3(VERR_SUPLIB_IS_FILE, pErrInfo,
    12031202                                      "Expected directory but found file: '", pszPath, "'");
    12041203    }
     
    12221221 * @param   pszPath             The path to the object @a pFsObjState
    12231222 *                              describes.  (For the error message.)
    1224  * @param   pszErr              The error buffer.
    1225  * @param   cbErr               The size of the error buffer.
     1223 * @param   pErrInfo            The error info structure.
    12261224 */
    12271225static int supR3HardenedVerifySameFsObject(RTHCUINTPTR hNative, PCSUPR3HARDENEDFSOBJSTATE pFsObjState,
    1228                                            const char *pszPath, char *pszErr, size_t cbErr)
     1226                                           const char *pszPath, PRTERRINFO pErrInfo)
    12291227{
    12301228    SUPR3HARDENEDFSOBJSTATE FsObjState2;
    1231     int rc = supR3HardenedQueryFsObjectByHandle(hNative, &FsObjState2, pszPath, pszErr, cbErr);
     1229    int rc = supR3HardenedQueryFsObjectByHandle(hNative, &FsObjState2, pszPath, pErrInfo);
    12321230    if (RT_SUCCESS(rc))
    1233         rc = supR3HardenedIsSameFsObject(pFsObjState, &FsObjState2, pszPath, pszErr, cbErr);
     1231        rc = supR3HardenedIsSameFsObject(pFsObjState, &FsObjState2, pszPath, pErrInfo);
    12341232    return rc;
    12351233}
     
    12521250 *                              thing.
    12531251 * @param   fRecursive          Whether to recurse into subdirectories.
    1254  * @param   pszErr              The error buffer.
    1255  * @param   cbErr               The size of the error buffer.
     1252 * @param   pErrInfo            The error info structure.
    12561253 */
    12571254static int supR3HardenedVerifyDirRecursive(char *pszDirPath, size_t cchDirPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState,
    1258                                            bool fRecursive, char *pszErr, size_t cbErr)
     1255                                           bool fRecursive, PRTERRINFO pErrInfo)
    12591256{
    12601257#if defined(RT_OS_WINDOWS)
     
    12781275        if (errno == EACCES)
    12791276            return VINF_SUCCESS;
    1280         return supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pszErr, cbErr,
     1277        return supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pErrInfo,
    12811278                                      5, "opendir failed with ", strerror(errno), " on '", pszDirPath, "'");
    12821279    }
    12831280    if (dirfd(pDir) != -1)
    12841281    {
    1285         int rc = supR3HardenedVerifySameFsObject(dirfd(pDir), pFsObjState, pszDirPath, pszErr, cbErr);
     1282        int rc = supR3HardenedVerifySameFsObject(dirfd(pDir), pFsObjState, pszDirPath, pErrInfo);
    12861283        if (RT_FAILURE(rc))
    12871284        {
     
    13041301        if (iErr)
    13051302        {
    1306             rc = supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pszErr, cbErr,
     1303            rc = supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pErrInfo,
    13071304                                        5, "readdir_r failed with ", strerror(iErr), " in '", pszDirPath, "'");
    13081305            break;
     
    13181315        if (cchName + cchDirPath > SUPR3HARDENED_MAX_PATH)
    13191316        {
    1320             rc = supR3HardenedSetErrorN(VERR_SUPLIB_PATH_TOO_LONG, pszErr, cbErr,
     1317            rc = supR3HardenedSetErrorN(VERR_SUPLIB_PATH_TOO_LONG, pErrInfo,
    13211318                                        4, "Path grew too long during recursion: '", pszDirPath, pEntry->d_name, "'");
    13221319            break;
     
    13291326         * of extra checks doesn't hurt and neither requires relaxed handling.)
    13301327         */
    1331         rc = supR3HardenedQueryFsObjectByPath(pszDirPath, pFsObjState, pszErr, cbErr);
     1328        rc = supR3HardenedQueryFsObjectByPath(pszDirPath, pFsObjState, pErrInfo);
    13321329        if (RT_SUCCESS(rc))
    13331330            break;
    13341331        rc = supR3HardenedVerifyFsObject(pFsObjState, S_ISDIR(pFsObjState->Stat.st_mode), false /*fRelaxed*/,
    1335                                          pszDirPath, pszErr, cbErr);
     1332                                         pszDirPath, pErrInfo);
    13361333        if (RT_FAILURE(rc))
    13371334            break;
     
    13491346
    13501347            rc = supR3HardenedVerifyDirRecursive(pszDirPath, cchDirPath + cchName + 1, pFsObjState,
    1351                                                  fRecursive, pszErr, cbErr);
     1348                                                 fRecursive, pErrInfo);
    13521349            if (RT_FAILURE(rc))
    13531350                break;
     
    13681365 * @param   fRecursive          See SUPR3HardenedVerifyDir.
    13691366 * @param   fCheckFiles         See SUPR3HardenedVerifyDir.
    1370  * @param   pszErr              See SUPR3HardenedVerifyDir.
    1371  * @param   cbErr               See SUPR3HardenedVerifyDir.
    1372  */
    1373 DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr)
     1367 * @param   pErrInfo            See SUPR3HardenedVerifyDir.
     1368 */
     1369DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo)
    13741370{
    13751371    /*
     
    13771373     */
    13781374    SUPR3HARDENEDPATHINFO Info;
    1379     int rc = supR3HardenedVerifyPathSanity(pszDirPath, pszErr, cbErr, &Info);
     1375    int rc = supR3HardenedVerifyPathSanity(pszDirPath, pErrInfo, &Info);
    13801376    if (RT_FAILURE(rc))
    13811377        return rc;
     
    13901386        bool fRelaxed = iComponent + 2 < cComponents;
    13911387        Info.szPath[Info.aoffComponents[iComponent + 1] - 1] = '\0';
    1392         rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pszErr, cbErr);
     1388        rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pErrInfo);
    13931389        if (RT_SUCCESS(rc))
    1394             rc = supR3HardenedVerifyFsObject(&FsObjState, true /*fDir*/, fRelaxed, Info.szPath, pszErr, cbErr);
     1390            rc = supR3HardenedVerifyFsObject(&FsObjState, true /*fDir*/, fRelaxed, Info.szPath, pErrInfo);
    13951391        if (RT_FAILURE(rc))
    13961392            return rc;
     
    14061402        Info.szPath[Info.cch + 1] = '\0';
    14071403        return supR3HardenedVerifyDirRecursive(Info.szPath, Info.cch + 1, &FsObjState,
    1408                                                fRecursive, pszErr, cbErr);
     1404                                               fRecursive, pErrInfo);
    14091405    }
    14101406
     
    14211417 *                              as we ended up with when verifying the path.
    14221418 *                              RTHCUINTPTR_MAX means NIL here.
    1423  * @param   pszErr              The error buffer.
    1424  * @param   cbErr               The size of the error buffer.
    1425  */
    1426 DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, char *pszErr, size_t cbErr)
     1419 * @param   pErrInfo            Where to return extended error information.
     1420 *                              Optional.
     1421 */
     1422DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, PRTERRINFO pErrInfo)
    14271423{
    14281424    /*
     
    14301426     */
    14311427    SUPR3HARDENEDPATHINFO Info;
    1432     int rc = supR3HardenedVerifyPathSanity(pszFilename, pszErr, cbErr, &Info);
     1428    int rc = supR3HardenedVerifyPathSanity(pszFilename, pErrInfo, &Info);
    14331429    if (RT_FAILURE(rc))
    14341430        return rc;
    14351431    if (Info.fDirSlash)
    1436         return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pszErr, cbErr,
     1432        return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pErrInfo,
    14371433                                      "The file path specifies a directory: '", pszFilename, "'");
    14381434
     
    14471443        bool fRelaxed = iComponent + 2 < cComponents;
    14481444        Info.szPath[Info.aoffComponents[iComponent + 1] - 1] = '\0';
    1449         rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pszErr, cbErr);
     1445        rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pErrInfo);
    14501446        if (RT_SUCCESS(rc))
    1451             rc = supR3HardenedVerifyFsObject(&FsObjState, !fFinal /*fDir*/, fRelaxed, Info.szPath, pszErr, cbErr);
     1447            rc = supR3HardenedVerifyFsObject(&FsObjState, !fFinal /*fDir*/, fRelaxed, Info.szPath, pErrInfo);
    14521448        if (RT_FAILURE(rc))
    14531449            return rc;
     
    14591455     */
    14601456    if (hNativeFile != RTHCUINTPTR_MAX)
    1461         return supR3HardenedVerifySameFsObject(hNativeFile, &FsObjState, Info.szPath, pszErr, cbErr);
     1457        return supR3HardenedVerifySameFsObject(hNativeFile, &FsObjState, Info.szPath, pErrInfo);
    14621458    return VINF_SUCCESS;
    14631459}
  • trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp

    r34241 r35188  
    7070            case VINF_GETOPT_NOT_OPTION:
    7171            {
    72                 char szErr[4096+1024];
    73                 void *pvImageBase;
    74                 rc = SUPR3LoadModule(ValueUnion.psz, RTPathFilename(ValueUnion.psz), &pvImageBase, szErr, sizeof(szErr));
     72                void           *pvImageBase;
     73                RTERRINFOSTATIC ErrInfo;
     74                RTErrInfoInitStatic(&ErrInfo);
     75                rc = SUPR3LoadModule(ValueUnion.psz, RTPathFilename(ValueUnion.psz), &pvImageBase, &ErrInfo.Core);
    7576                if (RT_FAILURE(rc))
    7677                {
    77                     RTMsgError("%Rrc when attempting to load '%s': %s\n", rc, ValueUnion.psz, szErr);
     78                    RTMsgError("%Rrc when attempting to load '%s': %s\n", rc, ValueUnion.psz, ErrInfo.Core.pszMsg);
    7879                    return 1;
    7980                }
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r35152 r35188  
    23352335    if (mVRDPLibrary == NIL_RTLDRMOD)
    23362336    {
    2337         char szErr[4096 + 512];
    2338         szErr[0] = '\0';
     2337        RTERRINFOSTATIC ErrInfo;
     2338        RTErrInfoInitStatic(&ErrInfo);
     2339
    23392340        if (RTPathHavePath(pszLibraryName))
    2340             rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, szErr, sizeof(szErr));
     2341            rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, &ErrInfo.Core);
    23412342        else
    2342             rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /*=fFlags*/, szErr, sizeof(szErr));
     2343            rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /*fFlags*/, &ErrInfo.Core);
    23432344        if (RT_SUCCESS(rc))
    23442345        {
     
    23712372        else
    23722373        {
    2373             if (szErr[0])
    2374                 LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, szErr, rc));
     2374            if (RTErrInfoIsSet(&ErrInfo.Core))
     2375                LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, ErrInfo.Core.pszMsg, rc));
    23752376            else
    23762377                LogRel(("VRDE: Error loading the library '%s' rc = %Rrc.\n", pszLibraryName, rc));
  • trunk/src/VBox/Main/ExtPackManagerImpl.cpp

    r35184 r35188  
    11231123    }
    11241124
    1125     char szErr[2048];
    1126     RT_ZERO(szErr);
    1127     vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr));
     1125    RTERRINFOSTATIC ErrInfo;
     1126    RTErrInfoInitStatic(&ErrInfo);
     1127    vrc = SUPR3HardenedVerifyDir(m->strExtPackPath.c_str(), true /*fRecursive*/, true /*fCheckFiles*/, &ErrInfo.Core);
    11281128    if (RT_FAILURE(vrc))
    11291129    {
    1130         m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), szErr, vrc);
     1130        m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), ErrInfo.Core.pszMsg, vrc);
    11311131        return;
    11321132    }
     
    11681168    }
    11691169
    1170     vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), szErr, sizeof(szErr));
     1170    vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), &ErrInfo.Core);
    11711171    if (RT_FAILURE(vrc))
    11721172    {
    1173         m->strWhyUnusable.printf(tr("%s"), szErr);
     1173        m->strWhyUnusable.printf(tr("%s"), ErrInfo.Core.pszMsg);
    11741174        return;
    11751175    }
    11761176
    1177     RTERRINFOSTATIC ErrInfo;
    1178     RTErrInfoInitStatic(&ErrInfo);
    11791177    if (fIsNative)
    11801178    {
     
    17731771    if (a_enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON)
    17741772    {
    1775         char szError[8192];
    1776         int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRFLAGS_GLOBAL, szError, sizeof(szError));
     1773        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRFLAGS_GLOBAL, NULL);
    17771774        if (RT_FAILURE(vrc))
    17781775            m->hVBoxVMM = NIL_RTLDRMOD;
  • trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp

    r35100 r35188  
    309309    RTMsgInfo("Validating unpacked extension pack...");
    310310
    311     char szErr[4096+1024];
    312     int rc = SUPR3HardenedVerifyDir(pszDir, true /*fRecursive*/, true /*fCheckFiles*/, szErr, sizeof(szErr));
    313     if (RT_FAILURE(rc))
    314         return RTMsgErrorExit(RTEXITCODE_FAILURE, "Hardening check failed with %Rrc: %s", rc, szErr);
     311    RTERRINFOSTATIC ErrInfo;
     312    RTErrInfoInitStatic(&ErrInfo);
     313    int rc = SUPR3HardenedVerifyDir(pszDir, true /*fRecursive*/, true /*fCheckFiles*/, &ErrInfo.Core);
     314    if (RT_FAILURE(rc))
     315        return RTMsgErrorExit(RTEXITCODE_FAILURE, "Hardening check failed with %Rrc: %s", rc, ErrInfo.Core.pszMsg);
    315316    return RTEXITCODE_SUCCESS;
    316317}
     
    14801481        return RTMsgInitFailure(rc);
    14811482
    1482     char szErr[2048];
    1483     rc = SUPR3HardenedVerifySelf(argv[0], true /*fInternal*/, szErr, sizeof(szErr));
    1484     if (RT_FAILURE(rc))
    1485         return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s", szErr);
     1483    RTERRINFOSTATIC ErrInfo;
     1484    RTErrInfoInitStatic(&ErrInfo);
     1485    rc = SUPR3HardenedVerifySelf(argv[0], true /*fInternal*/, &ErrInfo.Core);
     1486    if (RT_FAILURE(rc))
     1487        return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s", ErrInfo.Core.pszMsg);
    14861488
    14871489    /*
  • trunk/src/VBox/Main/VRDEServerImpl.cpp

    r35152 r35188  
    489489    RTLDRMOD hmod = NIL_RTLDRMOD;
    490490
    491     char szErr[4096 + 512];
    492     szErr[0] = '\0';
     491    RTERRINFOSTATIC ErrInfo;
     492    RTErrInfoInitStatic(&ErrInfo);
    493493    if (RTPathHavePath(pszLibraryName))
    494         rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, szErr, sizeof(szErr));
     494        rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, &ErrInfo.Core);
    495495    else
    496         rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /*=fFlags*/, szErr, sizeof(szErr));
     496        rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /*fFlags*/, &ErrInfo.Core);
    497497    if (RT_SUCCESS(rc))
    498498    {
     
    504504    else
    505505    {
    506         if (szErr[0])
    507             LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, szErr, rc));
     506        if (RTErrInfoIsSet(&ErrInfo.Core))
     507            LogRel(("VRDE: Error loading the library '%s': %s (%Rrc)\n", pszLibraryName, ErrInfo.Core.pszMsg, rc));
    508508        else
    509509            LogRel(("VRDE: Error loading the library '%s' rc = %Rrc.\n", pszLibraryName, rc));
  • trunk/src/VBox/Main/hgcm/HGCM.cpp

    r35152 r35188  
    262262    }
    263263
    264     char szErr[8192];
    265     szErr[0] = '\0';
    266     int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod, 0 /*=fFlags*/, szErr, sizeof(szErr));
     264    RTERRINFOSTATIC ErrInfo;
     265    RTErrInfoInitStatic (&ErrInfo);
     266
     267    int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod, 0 /*fFlags*/, &ErrInfo.Core);
    267268
    268269    if (RT_SUCCESS(rc))
     
    320321    {
    321322        LogRel(("HGCM: Failed to load the service library: [%s], rc = %Rrc - %s. The service will be not available.\n",
    322                 m_pszSvcLibrary, rc, szErr));
     323                m_pszSvcLibrary, rc, ErrInfo.Core.pszMsg));
    323324        m_hLdrMod = NIL_RTLDRMOD;
    324325    }
  • trunk/src/VBox/Storage/VD.cpp

    r35152 r35188  
    21292129        }
    21302130
    2131         rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);
     2131        rc = SUPR3HardenedLdrLoadPlugIn(pszPluginPath, &hPlugin, NULL);
    21322132        if (RT_SUCCESS(rc))
    21332133        {
     
    22532253        }
    22542254
    2255         rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);
     2255        rc = SUPR3HardenedLdrLoadPlugIn(pszPluginPath, &hPlugin, NULL);
    22562256        if (RT_SUCCESS(rc))
    22572257        {
  • 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.

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