Changeset 35188 in vbox for trunk/src/VBox
- Timestamp:
- Dec 16, 2010 3:13:07 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69027
- Location:
- trunk/src/VBox
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r35172 r35188 835 835 if (fFFMPEG) 836 836 { 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; 840 840 841 841 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); 843 844 844 845 if (RT_SUCCESS(rrc)) … … 861 862 "you wish to use is supported on your system\n", rcc); 862 863 } 863 if (RT_SUCCESS(rrc) && (rcc == S_OK))864 if (RT_SUCCESS(rrc) && rcc == S_OK) 864 865 { 865 866 Log2(("VBoxHeadless: Registering framebuffer\n")); … … 867 868 display->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, pFramebuffer); 868 869 } 869 if (!RT_SUCCESS(rrc) || (rcc != S_OK))870 if (!RT_SUCCESS(rrc) || rcc != S_OK) 870 871 rc = E_FAIL; 871 872 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r35152 r35188 5113 5113 if (mDbgEnabled) 5114 5114 { 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); 5118 5118 if (RT_FAILURE(vrc)) 5119 5119 { 5120 5120 mhVBoxDbg = NIL_RTLDRMOD; 5121 5121 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)); 5123 5123 } 5124 5124 } -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r35183 r35188 1438 1438 1439 1439 1440 SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, char *pszErr, size_t cbErr)1440 SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, PRTERRINFO pErrInfo) 1441 1441 { 1442 1442 /* … … 1444 1444 */ 1445 1445 AssertPtr(pszArgv0); 1446 AssertPtr(pszErr); 1447 Assert(cbErr > 32); 1446 RTErrInfoClear(pErrInfo); 1448 1447 1449 1448 /* … … 1452 1451 char szExecPath[RTPATH_MAX]; 1453 1452 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"); 1458 1454 1459 1455 int rc; … … 1465 1461 */ 1466 1462 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); 1471 1465 1472 1466 /* … … 1477 1471 rc = RTPathAppPrivateArch(szAppPrivateArch, sizeof(szAppPrivateArch)); 1478 1472 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); 1483 1475 size_t cchAppPrivateArch = strlen(szAppPrivateArch); 1484 1476 if ( cchAppPrivateArch >= strlen(szExecPath) 1485 1477 || !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"); 1490 1480 szExecPath[cchAppPrivateArch] = '\0'; 1491 1481 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"); 1496 1484 szExecPath[cchAppPrivateArch] = RTPATH_SLASH; 1497 1485 } … … 1501 1489 * Verify that the image file and parent directories are sane. 1502 1490 */ 1503 rc = supR3HardenedVerifyFile(szExecPath, RTHCUINTPTR_MAX, p szErr, cbErr);1491 rc = supR3HardenedVerifyFile(szExecPath, RTHCUINTPTR_MAX, pErrInfo); 1504 1492 if (RT_FAILURE(rc)) 1505 1493 return rc; … … 1510 1498 1511 1499 1512 SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, char *pszErr, size_t cbErr)1500 SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo) 1513 1501 { 1514 1502 /* … … 1516 1504 */ 1517 1505 AssertPtr(pszDirPath); 1518 AssertPtr(pszErr); 1519 Assert(cbErr > 32); 1506 RTErrInfoClear(pErrInfo); 1520 1507 1521 1508 /* … … 1523 1510 */ 1524 1511 #ifdef VBOX_WITH_HARDENING 1525 int rc = supR3HardenedVerifyDir(pszDirPath, fRecursive, fCheckFiles, p szErr, cbErr);1526 if (RT_FAILURE(rc) && (!pszErr || !cbErr))1512 int rc = supR3HardenedVerifyDir(pszDirPath, fRecursive, fCheckFiles, pErrInfo); 1513 if (RT_FAILURE(rc) && !RTErrInfoIsSet(pErrInfo)) 1527 1514 LogRel(("supR3HardenedVerifyDir: Verification of \"%s\" failed, rc=%Rrc\n", pszDirPath, rc)); 1528 1515 return rc; … … 1533 1520 1534 1521 1535 SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, char *pszErr, size_t cbErr)1522 SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, PRTERRINFO pErrInfo) 1536 1523 { 1537 1524 /* … … 1539 1526 */ 1540 1527 AssertPtr(pszFilename); 1541 AssertPtr(pszErr); 1542 Assert(cbErr > 32); 1528 RTErrInfoClear(pErrInfo); 1543 1529 1544 1530 /* … … 1546 1532 */ 1547 1533 #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)) 1550 1536 LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc)); 1551 1537 return rc; … … 1556 1542 1557 1543 1558 SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, char *pszErr, size_t cbErr)1544 SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo) 1559 1545 { 1560 1546 /* 1561 1547 * Check that the module can be trusted. 1562 1548 */ 1563 int rc = SUPR3HardenedVerifyPlugIn(pszFilename, p szErr, cbErr);1549 int rc = SUPR3HardenedVerifyPlugIn(pszFilename, pErrInfo); 1564 1550 if (RT_SUCCESS(rc)) 1565 1551 { 1566 1552 rc = supLoadModule(pszFilename, pszModule, NULL, ppvImageBase); 1567 1553 if (RT_FAILURE(rc)) 1568 RT StrPrintf(pszErr, cbErr, "supLoadModule returned %Rrc", rc);1554 RTErrInfoSetF(pErrInfo, rc, "supLoadModule returned %Rrc", rc); 1569 1555 } 1570 1556 return rc; … … 2055 2041 { 2056 2042 void *pvImageBase; 2057 return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL , 0);2043 return SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase, NULL /*pErrInfo*/); 2058 2044 } 2059 2045 … … 2084 2070 * @param phLdrMod Where to store the handle to the loaded module. 2085 2071 * @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 * 2088 2075 */ 2089 static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)2076 static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo) 2090 2077 { 2091 2078 #ifdef VBOX_WITH_HARDENING … … 2097 2084 { 2098 2085 LogRel(("supR3HardenedLdrLoadIt: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc)); 2099 return rc;2086 return RTErrInfoSet(pErrInfo, rc, "supR3HardenedVerifyFixedFile failed"); 2100 2087 } 2101 2088 #endif … … 2104 2091 * Try load it. 2105 2092 */ 2106 RTERRINFO ErrInfo;2107 PRTERRINFO pErrInfo;2108 if (!pszError || !cbError)2109 pErrInfo = NULL;2110 else2111 pErrInfo = RTErrInfoInit(&ErrInfo, pszError, cbError);2112 2093 return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, pErrInfo); 2113 2094 } 2114 2095 2115 2096 2116 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)2097 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo) 2117 2098 { 2118 2099 /* 2119 2100 * Validate input. 2120 2101 */ 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); 2131 2103 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 2132 2104 AssertPtrReturn(phLdrMod, VERR_INVALID_POINTER); … … 2152 2124 * Pass it on to the common library loader. 2153 2125 */ 2154 return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, p szError, 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 p szError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));2126 return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, pErrInfo); 2127 } 2128 2129 2130 SUPR3DECL(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)); 2161 2133 2162 2134 /* 2163 2135 * Validate input. 2164 2136 */ 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); 2175 2138 AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER); 2176 2139 *phLdrMod = NIL_RTLDRMOD; … … 2214 2177 * Pass it on to SUPR3HardenedLdrLoad. 2215 2178 */ 2216 rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, p szError, cbError);2179 rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, pErrInfo); 2217 2180 2218 2181 LogFlow(("SUPR3HardenedLdrLoadAppPriv: returns %Rrc\n", rc)); … … 2221 2184 2222 2185 2223 SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszErr, size_t cbErr)2186 SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo) 2224 2187 { 2225 2188 int rc; … … 2228 2191 * Validate input. 2229 2192 */ 2230 AssertPtr(pszErr); 2231 Assert(cbErr > 32); 2193 RTErrInfoClear(pErrInfo); 2232 2194 AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER); 2233 2195 *phLdrMod = NIL_RTLDRMOD; … … 2239 2201 * Verify the image file. 2240 2202 */ 2241 rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, p szErr, cbErr);2203 rc = supR3HardenedVerifyFile(pszFilename, RTHCUINTPTR_MAX, pErrInfo); 2242 2204 if (RT_FAILURE(rc)) 2243 2205 { 2244 if (! pszErr || !cbErr)2206 if (!RTErrInfoIsSet(pErrInfo)) 2245 2207 LogRel(("supR3HardenedVerifyFile: Verification of \"%s\" failed, rc=%Rrc\n", pszFilename, rc)); 2246 2208 return rc; … … 2251 2213 * Try load it. 2252 2214 */ 2253 RTERRINFO ErrInfo;2254 PRTERRINFO pErrInfo;2255 if (!pszErr || !cbErr)2256 pErrInfo = NULL;2257 else2258 pErrInfo = RTErrInfoInit(&ErrInfo, pszErr, cbErr);2259 2215 return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*fFlags*/, pErrInfo); 2260 2216 } -
trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h
r33741 r35188 320 320 DECLHIDDEN(int) supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal); 321 321 DECLHIDDEN(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);322 DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo); 323 DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, PRTERRINFO pErrInfo); 324 324 DECLHIDDEN(void) supR3HardenedGetPreInitData(PSUPPREINITDATA pPreInitData); 325 325 DECLHIDDEN(int) supR3HardenedRecvPreInitData(PCSUPPREINITDATA pPreInitData); -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
r34563 r35188 764 764 * @returns Returns @a rc 765 765 * @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. 768 767 * @param cMsgs The number of messages in the ellipsis. 769 768 * @param ... Message parts. 770 769 */ 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); 770 static 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 } 787 795 788 796 return rc; … … 795 803 * @returns Returns @a rc 796 804 * @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. 799 806 * @param pszMsg1 The first message part. 800 807 * @param pszMsg2 The second message part. 801 808 * @param pszMsg3 The third message part. 802 809 */ 803 static int supR3HardenedSetError3(int rc, char *pszErr, size_t cbErr, const char *pszMsg1,810 static int supR3HardenedSetError3(int rc, PRTERRINFO pErrInfo, const char *pszMsg1, 804 811 const char *pszMsg2, const char *pszMsg3) 805 812 { 806 return supR3HardenedSetErrorN(rc, p szErr, cbErr, 3, pszMsg1, pszMsg2, pszMsg3);813 return supR3HardenedSetErrorN(rc, pErrInfo, 3, pszMsg1, pszMsg2, pszMsg3); 807 814 } 808 815 … … 813 820 * @returns Returns @a rc 814 821 * @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. 817 823 * @param pszMsg1 The first message part. 818 824 * @param pszMsg2 The second message part. 819 825 */ 820 static int supR3HardenedSetError2(int rc, char *pszErr, size_t cbErr, const char *pszMsg1,826 static int supR3HardenedSetError2(int rc, PRTERRINFO pErrInfo, const char *pszMsg1, 821 827 const char *pszMsg2) 822 828 { 823 return supR3HardenedSetErrorN(rc, p szErr, cbErr, 2, pszMsg1, pszMsg2);829 return supR3HardenedSetErrorN(rc, pErrInfo, 2, pszMsg1, pszMsg2); 824 830 } 825 831 … … 830 836 * @returns Returns @a rc 831 837 * @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. 834 839 * @param pszMsg The message. 835 840 */ 836 static int supR3HardenedSetError(int rc, char *pszErr, size_t cbErr, const char *pszMsg)837 { 838 return supR3HardenedSetErrorN(rc, p szErr, cbErr, 1, pszMsg);841 static int supR3HardenedSetError(int rc, PRTERRINFO pErrInfo, const char *pszMsg) 842 { 843 return supR3HardenedSetErrorN(rc, pErrInfo, 1, pszMsg); 839 844 } 840 845 … … 877 882 * @returns VBox status code. 878 883 * @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. 881 885 * @param pInfo Where to return a copy of the path along with 882 886 * parsing information. 883 887 */ 884 static int supR3HardenedVerifyPathSanity(const char *pszPath, char *pszErr, size_t cbErr, PSUPR3HARDENEDPATHINFO pInfo)888 static int supR3HardenedVerifyPathSanity(const char *pszPath, PRTERRINFO pErrInfo, PSUPR3HARDENEDPATHINFO pInfo) 885 889 { 886 890 const char *pszSrc = pszPath; … … 894 898 || pszSrc[1] != ':' 895 899 || !RTPATH_IS_SLASH(pszSrc[2])) 896 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, p szErr, cbErr, "The path is not absolute: '", pszPath, "'");900 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, "The path is not absolute: '", pszPath, "'"); 897 901 898 902 *pszDst++ = RT_C_TO_UPPER(pszSrc[0]); … … 903 907 #else 904 908 if (!RTPATH_IS_SLASH(pszSrc[0])) 905 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, p szErr, cbErr, "The path is not absolute: '", pszPath, "'");909 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, "The path is not absolute: '", pszPath, "'"); 906 910 907 911 *pszDst++ = RTPATH_SLASH; … … 914 918 */ 915 919 if (pszSrc[0] == '\0') 916 return supR3HardenedSetError3(VERR_SUPLIB_PATH_IS_ROOT, p szErr, cbErr, "The path is root: '", pszPath, "'");920 return supR3HardenedSetError3(VERR_SUPLIB_PATH_IS_ROOT, pErrInfo, "The path is root: '", pszPath, "'"); 917 921 if ( pszSrc[1] == '\0' 918 922 || pszSrc[2] == '\0') 919 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_SHORT, p szErr, cbErr, "The path is too short: '", pszPath, "'");923 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_SHORT, pErrInfo, "The path is too short: '", pszPath, "'"); 920 924 921 925 /* … … 928 932 /* Sanity checks. */ 929 933 if (RTPATH_IS_SLASH(pszSrc[0])) /* can be relaxed if we care. */ 930 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_CLEAN, p szErr, cbErr,934 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_CLEAN, pErrInfo, 931 935 "The path is not clean of double slashes: '", pszPath, "'"); 932 936 if ( pszSrc[0] == '.' 933 937 && pszSrc[1] == '.' 934 938 && RTPATH_IS_SLASH(pszSrc[2])) 935 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, p szErr, cbErr,939 return supR3HardenedSetError3(VERR_SUPLIB_PATH_NOT_ABSOLUTE, pErrInfo, 936 940 "The path is not absolute: '", pszPath, "'"); 937 941 938 942 /* Record the start of the component. */ 939 943 if (pInfo->cComponents >= RT_ELEMENTS(pInfo->aoffComponents) - 1) 940 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_MANY_COMPONENTS, p szErr, cbErr,944 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_MANY_COMPONENTS, pErrInfo, 941 945 "The path has too many components: '", pszPath, "'"); 942 946 pInfo->aoffComponents[pInfo->cComponents++] = pszDst - &pInfo->szPath[0]; … … 956 960 *pszDst++ = *pszSrc++; 957 961 if ((uintptr_t)(pszDst - &pInfo->szPath[0]) >= SUPR3HARDENED_MAX_PATH) 958 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_LONG, p szErr, cbErr,962 return supR3HardenedSetError3(VERR_SUPLIB_PATH_TOO_LONG, pErrInfo, 959 963 "The path is too long: '", pszPath, "'"); 960 964 } … … 1000 1004 * @param pszPath The path to the object. 1001 1005 * @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 */ 1008 static int supR3HardenedQueryFsObjectByPath(char const *pszPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState, PRTERRINFO pErrInfo) 1007 1009 { 1008 1010 #if defined(RT_OS_WINDOWS) … … 1019 1021 /* Ignore access errors */ 1020 1022 if (errno != EACCES) 1021 return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, p szErr, cbErr,1023 return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pErrInfo, 1022 1024 5, "stat failed with ", strerror(errno), " on: '", pszPath, "'"); 1023 1025 } … … 1043 1045 * @param pszPath The path to the object. (For the error message 1044 1046 * only.) 1045 * @param pszErr The error buffer. 1046 * @param cbErr The size of the error buffer. 1047 * @param pErrInfo The error info structure. 1047 1048 */ 1048 1049 static int supR3HardenedQueryFsObjectByHandle(RTHCUINTPTR hNative, PSUPR3HARDENEDFSOBJSTATE pFsObjState, 1049 char const *pszPath, char *pszErr, size_t cbErr)1050 char const *pszPath, PRTERRINFO pErrInfo) 1050 1051 { 1051 1052 #if defined(RT_OS_WINDOWS) … … 1059 1060 */ 1060 1061 if (fstat((int)hNative, &pFsObjState->Stat) != 0) 1061 return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, p szErr, cbErr,1062 return supR3HardenedSetErrorN(VERR_SUPLIB_STAT_FAILED, pErrInfo, 1062 1063 5, "fstat failed with ", strerror(errno), " on '", pszPath, "'"); 1063 1064 … … 1081 1082 * @param pszPath The path to the object @a pFsObjState 1082 1083 * 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. 1085 1085 */ 1086 1086 static int supR3HardenedIsSameFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState1, PCSUPR3HARDENEDFSOBJSTATE pFsObjState2, 1087 const char *pszPath, char *pszErr, size_t cbErr)1087 const char *pszPath, PRTERRINFO pErrInfo) 1088 1088 { 1089 1089 #if defined(RT_OS_WINDOWS) … … 1101 1101 if ( pFsObjState1->Stat.st_ino != pFsObjState2->Stat.st_ino 1102 1102 || pFsObjState1->Stat.st_dev != pFsObjState2->Stat.st_dev) 1103 return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, p szErr, cbErr,1103 return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo, 1104 1104 "The native handle is not the same as '", pszPath, "' (ino/dev)"); 1105 1105 if ( pFsObjState1->Stat.st_uid != pFsObjState2->Stat.st_uid 1106 1106 || pFsObjState1->Stat.st_gid != pFsObjState2->Stat.st_gid) 1107 return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, p szErr, cbErr,1107 return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo, 1108 1108 "The native handle is not the same as '", pszPath, "' (uid/gid)"); 1109 1109 if ( (pFsObjState1->Stat.st_mode & (S_IFMT | S_IWUSR | S_IWGRP | S_IWOTH)) 1110 1110 != (pFsObjState2->Stat.st_mode & (S_IFMT | S_IWUSR | S_IWGRP | S_IWOTH))) 1111 return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, p szErr, cbErr,1111 return supR3HardenedSetError3(VERR_SUPLIB_NOT_SAME_OBJECT, pErrInfo, 1112 1112 "The native handle is not the same as '", pszPath, "' (mode)"); 1113 1113 return VINF_SUCCESS; … … 1128 1128 * @param pszPath The path to the object. (For error messages 1129 1129 * only.) 1130 * @param pszErr The error buffer. 1131 * @param cbErr The size of the error buffer. 1130 * @param pErrInfo The error info structure. 1132 1131 */ 1133 1132 static int supR3HardenedVerifyFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState, bool fDir, bool fRelaxed, 1134 const char *pszPath, char *pszErr, size_t cbErr)1133 const char *pszPath, PRTERRINFO pErrInfo) 1135 1134 { 1136 1135 #if defined(RT_OS_WINDOWS) … … 1149 1148 */ 1150 1149 if (pFsObjState->Stat.st_uid != 0) 1151 return supR3HardenedSetError3(VERR_SUPLIB_OWNER_NOT_ROOT, p szErr, cbErr, "The owner is not root: '", pszPath, "'");1150 return supR3HardenedSetError3(VERR_SUPLIB_OWNER_NOT_ROOT, pErrInfo, "The owner is not root: '", pszPath, "'"); 1152 1151 1153 1152 /* … … 1167 1166 if (pFsObjState->Stat.st_gid != 80 /*admin*/) /** @todo dynamically resolve the admin group? */ 1168 1167 #endif 1169 return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, p szErr, cbErr,1168 return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pErrInfo, 1170 1169 "The group is not a system group and it has write access to '", pszPath, "'"); 1171 1170 } … … 1175 1174 */ 1176 1175 if (pFsObjState->Stat.st_mode & S_IWOTH) 1177 return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, p szErr, cbErr,1176 return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pErrInfo, 1178 1177 "World writable: '", pszPath, "'"); 1179 1178 … … 1190 1189 { 1191 1190 if (S_ISLNK(pFsObjState->Stat.st_mode)) 1192 return supR3HardenedSetError3(VERR_SUPLIB_SYMLINKS_ARE_NOT_PERMITTED, p szErr, cbErr,1191 return supR3HardenedSetError3(VERR_SUPLIB_SYMLINKS_ARE_NOT_PERMITTED, pErrInfo, 1193 1192 "Symlinks are not permitted: '", pszPath, "'"); 1194 return supR3HardenedSetError3(VERR_SUPLIB_NOT_DIR_NOT_FILE, p szErr, cbErr,1193 return supR3HardenedSetError3(VERR_SUPLIB_NOT_DIR_NOT_FILE, pErrInfo, 1195 1194 "Not regular file or directory: '", pszPath, "'"); 1196 1195 } … … 1198 1197 { 1199 1198 if (S_ISDIR(pFsObjState->Stat.st_mode)) 1200 return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, p szErr, cbErr,1199 return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pErrInfo, 1201 1200 "Expected file but found directory: '", pszPath, "'"); 1202 return supR3HardenedSetError3(VERR_SUPLIB_IS_FILE, p szErr, cbErr,1201 return supR3HardenedSetError3(VERR_SUPLIB_IS_FILE, pErrInfo, 1203 1202 "Expected directory but found file: '", pszPath, "'"); 1204 1203 } … … 1222 1221 * @param pszPath The path to the object @a pFsObjState 1223 1222 * 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. 1226 1224 */ 1227 1225 static int supR3HardenedVerifySameFsObject(RTHCUINTPTR hNative, PCSUPR3HARDENEDFSOBJSTATE pFsObjState, 1228 const char *pszPath, char *pszErr, size_t cbErr)1226 const char *pszPath, PRTERRINFO pErrInfo) 1229 1227 { 1230 1228 SUPR3HARDENEDFSOBJSTATE FsObjState2; 1231 int rc = supR3HardenedQueryFsObjectByHandle(hNative, &FsObjState2, pszPath, p szErr, cbErr);1229 int rc = supR3HardenedQueryFsObjectByHandle(hNative, &FsObjState2, pszPath, pErrInfo); 1232 1230 if (RT_SUCCESS(rc)) 1233 rc = supR3HardenedIsSameFsObject(pFsObjState, &FsObjState2, pszPath, p szErr, cbErr);1231 rc = supR3HardenedIsSameFsObject(pFsObjState, &FsObjState2, pszPath, pErrInfo); 1234 1232 return rc; 1235 1233 } … … 1252 1250 * thing. 1253 1251 * @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. 1256 1253 */ 1257 1254 static int supR3HardenedVerifyDirRecursive(char *pszDirPath, size_t cchDirPath, PSUPR3HARDENEDFSOBJSTATE pFsObjState, 1258 bool fRecursive, char *pszErr, size_t cbErr)1255 bool fRecursive, PRTERRINFO pErrInfo) 1259 1256 { 1260 1257 #if defined(RT_OS_WINDOWS) … … 1278 1275 if (errno == EACCES) 1279 1276 return VINF_SUCCESS; 1280 return supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, p szErr, cbErr,1277 return supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pErrInfo, 1281 1278 5, "opendir failed with ", strerror(errno), " on '", pszDirPath, "'"); 1282 1279 } 1283 1280 if (dirfd(pDir) != -1) 1284 1281 { 1285 int rc = supR3HardenedVerifySameFsObject(dirfd(pDir), pFsObjState, pszDirPath, p szErr, cbErr);1282 int rc = supR3HardenedVerifySameFsObject(dirfd(pDir), pFsObjState, pszDirPath, pErrInfo); 1286 1283 if (RT_FAILURE(rc)) 1287 1284 { … … 1304 1301 if (iErr) 1305 1302 { 1306 rc = supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, p szErr, cbErr,1303 rc = supR3HardenedSetErrorN(VERR_SUPLIB_DIR_ENUM_FAILED, pErrInfo, 1307 1304 5, "readdir_r failed with ", strerror(iErr), " in '", pszDirPath, "'"); 1308 1305 break; … … 1318 1315 if (cchName + cchDirPath > SUPR3HARDENED_MAX_PATH) 1319 1316 { 1320 rc = supR3HardenedSetErrorN(VERR_SUPLIB_PATH_TOO_LONG, p szErr, cbErr,1317 rc = supR3HardenedSetErrorN(VERR_SUPLIB_PATH_TOO_LONG, pErrInfo, 1321 1318 4, "Path grew too long during recursion: '", pszDirPath, pEntry->d_name, "'"); 1322 1319 break; … … 1329 1326 * of extra checks doesn't hurt and neither requires relaxed handling.) 1330 1327 */ 1331 rc = supR3HardenedQueryFsObjectByPath(pszDirPath, pFsObjState, p szErr, cbErr);1328 rc = supR3HardenedQueryFsObjectByPath(pszDirPath, pFsObjState, pErrInfo); 1332 1329 if (RT_SUCCESS(rc)) 1333 1330 break; 1334 1331 rc = supR3HardenedVerifyFsObject(pFsObjState, S_ISDIR(pFsObjState->Stat.st_mode), false /*fRelaxed*/, 1335 pszDirPath, p szErr, cbErr);1332 pszDirPath, pErrInfo); 1336 1333 if (RT_FAILURE(rc)) 1337 1334 break; … … 1349 1346 1350 1347 rc = supR3HardenedVerifyDirRecursive(pszDirPath, cchDirPath + cchName + 1, pFsObjState, 1351 fRecursive, p szErr, cbErr);1348 fRecursive, pErrInfo); 1352 1349 if (RT_FAILURE(rc)) 1353 1350 break; … … 1368 1365 * @param fRecursive See SUPR3HardenedVerifyDir. 1369 1366 * @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 */ 1369 DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo) 1374 1370 { 1375 1371 /* … … 1377 1373 */ 1378 1374 SUPR3HARDENEDPATHINFO Info; 1379 int rc = supR3HardenedVerifyPathSanity(pszDirPath, p szErr, cbErr, &Info);1375 int rc = supR3HardenedVerifyPathSanity(pszDirPath, pErrInfo, &Info); 1380 1376 if (RT_FAILURE(rc)) 1381 1377 return rc; … … 1390 1386 bool fRelaxed = iComponent + 2 < cComponents; 1391 1387 Info.szPath[Info.aoffComponents[iComponent + 1] - 1] = '\0'; 1392 rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, p szErr, cbErr);1388 rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pErrInfo); 1393 1389 if (RT_SUCCESS(rc)) 1394 rc = supR3HardenedVerifyFsObject(&FsObjState, true /*fDir*/, fRelaxed, Info.szPath, p szErr, cbErr);1390 rc = supR3HardenedVerifyFsObject(&FsObjState, true /*fDir*/, fRelaxed, Info.szPath, pErrInfo); 1395 1391 if (RT_FAILURE(rc)) 1396 1392 return rc; … … 1406 1402 Info.szPath[Info.cch + 1] = '\0'; 1407 1403 return supR3HardenedVerifyDirRecursive(Info.szPath, Info.cch + 1, &FsObjState, 1408 fRecursive, p szErr, cbErr);1404 fRecursive, pErrInfo); 1409 1405 } 1410 1406 … … 1421 1417 * as we ended up with when verifying the path. 1422 1418 * RTHCUINTPTR_MAX means NIL here. 1423 * @param p szErr 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 */ 1422 DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, PRTERRINFO pErrInfo) 1427 1423 { 1428 1424 /* … … 1430 1426 */ 1431 1427 SUPR3HARDENEDPATHINFO Info; 1432 int rc = supR3HardenedVerifyPathSanity(pszFilename, p szErr, cbErr, &Info);1428 int rc = supR3HardenedVerifyPathSanity(pszFilename, pErrInfo, &Info); 1433 1429 if (RT_FAILURE(rc)) 1434 1430 return rc; 1435 1431 if (Info.fDirSlash) 1436 return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, p szErr, cbErr,1432 return supR3HardenedSetError3(VERR_SUPLIB_IS_DIRECTORY, pErrInfo, 1437 1433 "The file path specifies a directory: '", pszFilename, "'"); 1438 1434 … … 1447 1443 bool fRelaxed = iComponent + 2 < cComponents; 1448 1444 Info.szPath[Info.aoffComponents[iComponent + 1] - 1] = '\0'; 1449 rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, p szErr, cbErr);1445 rc = supR3HardenedQueryFsObjectByPath(Info.szPath, &FsObjState, pErrInfo); 1450 1446 if (RT_SUCCESS(rc)) 1451 rc = supR3HardenedVerifyFsObject(&FsObjState, !fFinal /*fDir*/, fRelaxed, Info.szPath, p szErr, cbErr);1447 rc = supR3HardenedVerifyFsObject(&FsObjState, !fFinal /*fDir*/, fRelaxed, Info.szPath, pErrInfo); 1452 1448 if (RT_FAILURE(rc)) 1453 1449 return rc; … … 1459 1455 */ 1460 1456 if (hNativeFile != RTHCUINTPTR_MAX) 1461 return supR3HardenedVerifySameFsObject(hNativeFile, &FsObjState, Info.szPath, p szErr, cbErr);1457 return supR3HardenedVerifySameFsObject(hNativeFile, &FsObjState, Info.szPath, pErrInfo); 1462 1458 return VINF_SUCCESS; 1463 1459 } -
trunk/src/VBox/HostDrivers/Support/testcase/tstSupLoadModule.cpp
r34241 r35188 70 70 case VINF_GETOPT_NOT_OPTION: 71 71 { 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); 75 76 if (RT_FAILURE(rc)) 76 77 { 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); 78 79 return 1; 79 80 } -
trunk/src/VBox/Main/ConsoleVRDPServer.cpp
r35152 r35188 2335 2335 if (mVRDPLibrary == NIL_RTLDRMOD) 2336 2336 { 2337 char szErr[4096 + 512]; 2338 szErr[0] = '\0'; 2337 RTERRINFOSTATIC ErrInfo; 2338 RTErrInfoInitStatic(&ErrInfo); 2339 2339 2340 if (RTPathHavePath(pszLibraryName)) 2340 rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, szErr, sizeof(szErr));2341 rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, &ErrInfo.Core); 2341 2342 else 2342 rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /* =fFlags*/, szErr, sizeof(szErr));2343 rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /*fFlags*/, &ErrInfo.Core); 2343 2344 if (RT_SUCCESS(rc)) 2344 2345 { … … 2371 2372 else 2372 2373 { 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)); 2375 2376 else 2376 2377 LogRel(("VRDE: Error loading the library '%s' rc = %Rrc.\n", pszLibraryName, rc)); -
trunk/src/VBox/Main/ExtPackManagerImpl.cpp
r35184 r35188 1123 1123 } 1124 1124 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); 1128 1128 if (RT_FAILURE(vrc)) 1129 1129 { 1130 m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), szErr, vrc);1130 m->strWhyUnusable.printf(tr("%s (rc=%Rrc)"), ErrInfo.Core.pszMsg, vrc); 1131 1131 return; 1132 1132 } … … 1168 1168 } 1169 1169 1170 vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), szErr, sizeof(szErr));1170 vrc = SUPR3HardenedVerifyPlugIn(m->strMainModPath.c_str(), &ErrInfo.Core); 1171 1171 if (RT_FAILURE(vrc)) 1172 1172 { 1173 m->strWhyUnusable.printf(tr("%s"), szErr);1173 m->strWhyUnusable.printf(tr("%s"), ErrInfo.Core.pszMsg); 1174 1174 return; 1175 1175 } 1176 1176 1177 RTERRINFOSTATIC ErrInfo;1178 RTErrInfoInitStatic(&ErrInfo);1179 1177 if (fIsNative) 1180 1178 { … … 1773 1771 if (a_enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON) 1774 1772 { 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); 1777 1774 if (RT_FAILURE(vrc)) 1778 1775 m->hVBoxVMM = NIL_RTLDRMOD; -
trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp
r35100 r35188 309 309 RTMsgInfo("Validating unpacked extension pack..."); 310 310 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); 315 316 return RTEXITCODE_SUCCESS; 316 317 } … … 1480 1481 return RTMsgInitFailure(rc); 1481 1482 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); 1486 1488 1487 1489 /* -
trunk/src/VBox/Main/VRDEServerImpl.cpp
r35152 r35188 489 489 RTLDRMOD hmod = NIL_RTLDRMOD; 490 490 491 char szErr[4096 + 512];492 szErr[0] = '\0';491 RTERRINFOSTATIC ErrInfo; 492 RTErrInfoInitStatic(&ErrInfo); 493 493 if (RTPathHavePath(pszLibraryName)) 494 rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, szErr, sizeof(szErr));494 rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, &ErrInfo.Core); 495 495 else 496 rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /* =fFlags*/, szErr, sizeof(szErr));496 rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /*fFlags*/, &ErrInfo.Core); 497 497 if (RT_SUCCESS(rc)) 498 498 { … … 504 504 else 505 505 { 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)); 508 508 else 509 509 LogRel(("VRDE: Error loading the library '%s' rc = %Rrc.\n", pszLibraryName, rc)); -
trunk/src/VBox/Main/hgcm/HGCM.cpp
r35152 r35188 262 262 } 263 263 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); 267 268 268 269 if (RT_SUCCESS(rc)) … … 320 321 { 321 322 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)); 323 324 m_hLdrMod = NIL_RTLDRMOD; 324 325 } -
trunk/src/VBox/Storage/VD.cpp
r35152 r35188 2129 2129 } 2130 2130 2131 rc = SUPR3HardenedLdrLoad (pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);2131 rc = SUPR3HardenedLdrLoadPlugIn(pszPluginPath, &hPlugin, NULL); 2132 2132 if (RT_SUCCESS(rc)) 2133 2133 { … … 2253 2253 } 2254 2254 2255 rc = SUPR3HardenedLdrLoad (pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);2255 rc = SUPR3HardenedLdrLoadPlugIn(pszPluginPath, &hPlugin, NULL); 2256 2256 if (RT_SUCCESS(rc)) 2257 2257 { -
trunk/src/VBox/VMM/PDMLdr.cpp
r34286 r35188 295 295 * Load the loader item. 296 296 */ 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); 299 300 if (RT_SUCCESS(rc)) 300 301 { … … 306 307 /* Something went wrong, most likely module not found. Don't consider other unlikely errors */ 307 308 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); 309 310 RTMemFree(pModule); 310 311 } … … 483 484 * Open the loader item. 484 485 */ 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); 487 489 if (RT_SUCCESS(rc)) 488 490 { 489 szErr[0] = '\0';491 RTErrInfoClear(&ErrInfo.Core); 490 492 rc = RTLdrOpen(pszFilename, 0, RTLDRARCH_X86_32, &pModule->hLdrMod); 491 493 } … … 565 567 566 568 /* 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); 569 571 else if (RT_FAILURE(rc)) 570 572 rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Cannot load RC module %s"), pszFilename); … … 633 635 * Ask the support library to load it. 634 636 */ 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); 638 641 if (RT_SUCCESS(rc)) 639 642 { … … 662 665 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 663 666 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)); 665 668 666 669 /* Don't consider VERR_PDM_MODULE_NAME_CLASH and VERR_NO_MEMORY above as these are very unlikely. */ 667 670 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); 669 672 670 673 RTMemTmpFree(pszFile); /* might be reference thru pszFilename in the above VMSetError call. */
Note:
See TracChangeset
for help on using the changeset viewer.