Changeset 66842 in vbox for trunk/src/VBox
- Timestamp:
- May 8, 2017 9:03:57 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115296
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
r66632 r66842 86 86 /** The max path length acceptable for a trusted path. */ 87 87 #define SUPR3HARDENED_MAX_PATH 260U 88 89 /** Enable to resolve symlinks using realpath() instead of cooking our own stuff. */ 90 #define SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH 1 88 91 89 92 #ifdef RT_OS_SOLARIS … … 1092 1095 1093 1096 1094 #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) 1097 #ifndef SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH 1098 # if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) 1095 1099 /** 1096 1100 * Copies the error message to the error buffer and returns @a rc. … … 1105 1109 return supR3HardenedSetErrorN(rc, pErrInfo, 1, pszMsg); 1106 1110 } 1111 # endif 1107 1112 #endif 1108 1113 … … 1894 1899 * Verify each component from the root up. 1895 1900 */ 1901 #ifndef SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH 1896 1902 uint32_t iLoops = 0; 1903 #endif 1897 1904 SUPR3HARDENEDFSOBJSTATE FsObjState; 1898 1905 uint32_t iComponent = 0; … … 1916 1923 && S_ISLNK(FsObjState.Stat.st_mode)) 1917 1924 { 1925 #if SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH /* Another approach using realpath() and verifying the result when encountering a symlink. */ 1926 char *pszFilenameResolved = realpath(pszFilename, NULL); 1927 if (pszFilenameResolved) 1928 { 1929 rc = supR3HardenedVerifyFile(pszFilenameResolved, hNativeFile, fMaybe3rdParty, pErrInfo); 1930 free(pszFilenameResolved); 1931 return rc; 1932 } 1933 else 1934 { 1935 int iErr = errno; 1936 supR3HardenedError(VERR_ACCESS_DENIED, false /*fFatal*/, 1937 "supR3HardenedVerifyFileFollowSymlinks: Failed to resolve the real path '%s': %s (%d)\n", 1938 pszFilename, strerror(iErr), iErr); 1939 return supR3HardenedSetError4(VERR_ACCESS_DENIED, pErrInfo, 1940 "realpath failed for '", pszFilename, "': ", strerror(iErr)); 1941 } 1942 #else 1918 1943 /* Don't loop forever. */ 1919 1944 iLoops++; … … 1990 2015 return supR3HardenedSetError3(VERR_TOO_MANY_SYMLINKS, pErrInfo, 1991 2016 "Too many symbolic links: '", pszFilename, "'"); 2017 #endif 1992 2018 } 1993 2019 }
Note:
See TracChangeset
for help on using the changeset viewer.