Changeset 26243 in vbox
- Timestamp:
- Feb 4, 2010 4:39:26 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuestLib.h
r26148 r26243 498 498 VBGLR3DECL(bool) VbglR3CredentialsAreAvailable(void); 499 499 VBGLR3DECL(int) VbglR3CredentialsRetrieve(char **ppszUser, char **ppszPassword, char **ppszDomain); 500 VBGLR3DECL(void) VbglR3CredentialsDestroy(char *pszUser, char *pszPassword, char *pszDomain, uint 8_t u8NumPasses);500 VBGLR3DECL(void) VbglR3CredentialsDestroy(char *pszUser, char *pszPassword, char *pszDomain, uint32_t cPasses); 501 501 /** @} */ 502 502 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibCredentials.cpp
r26149 r26243 24 24 * Header Files * 25 25 *******************************************************************************/ 26 #include <iprt/asm.h> 26 27 #include <iprt/string.h> 28 #include <iprt/rand.h> 27 29 #include <VBox/log.h> 28 30 … … 89 91 90 92 /** 91 * Clears and frees the strings93 * Clears and frees the three strings. 92 94 * 93 * @returns IPRT status value94 95 * @param pszUser Receives pointer of the user name string to destroy. 95 96 * Optional. … … 98 99 * @param pszDomain Receives pointer of allocated domain name string. 99 100 * Optional. 100 * @param u8NumPasses Number of wipe passes. The higher the better (and slower!).101 * @param cPasses Number of wipe passes. The more the better + slower. 101 102 */ 102 VBGLR3DECL(void) VbglR3CredentialsDestroy(char *pszUser, char *pszPassword, char *pszDomain, uint 8_t u8NumPasses)103 VBGLR3DECL(void) VbglR3CredentialsDestroy(char *pszUser, char *pszPassword, char *pszDomain, uint32_t cPasses) 103 104 { 104 size_t l; 105 size_t const cchUser = pszUser ? strlen(pszUser) : 0; 106 size_t const cchPassword = pszPassword ? strlen(pszPassword) : 0; 107 size_t const cchDomain = pszDomain ? strlen(pszDomain) : 0; 105 108 106 if (u8NumPasses == 0) /* We at least want to have one wipe pass. */ 107 u8NumPasses = 1; 109 do 110 { 111 if (cchUser) 112 memset(pszUser, 0xff, cchUser); 113 if (cchPassword) 114 memset(pszPassword, 0xff, cchPassword); 115 if (cchDomain) 116 memset(pszDomain, 0xff, cchDomain); 117 ASMMemoryFence(); 108 118 109 /** @todo add some for-loop with randomized content instead of 110 * zero'ing out the string only one time. Use u8NumPasses for that. */ 111 if (pszUser) 112 { 113 l = strlen(pszUser); 114 RT_BZERO(pszUser, l); 115 RTStrFree(pszUser); 116 } 117 if (pszPassword) 118 { 119 l = strlen(pszPassword); 120 RT_BZERO(pszPassword, l); 121 RTStrFree(pszPassword); 122 } 123 if (pszUser) 124 { 125 l = strlen(pszDomain); 126 RT_BZERO(pszDomain, l); 127 RTStrFree(pszDomain); 128 } 119 if (cchUser) 120 memset(pszUser, 0x00, cchUser); 121 if (cchPassword) 122 memset(pszPassword, 0x00, cchPassword); 123 if (cchDomain) 124 memset(pszDomain, 0x00, cchDomain); 125 ASMMemoryFence(); 126 127 if (cchUser) 128 RTRandBytes(pszUser, cchUser); 129 if (cchPassword) 130 RTRandBytes(pszPassword, cchPassword); 131 if (cchDomain) 132 RTRandBytes(pszDomain, cchDomain); 133 ASMMemoryFence(); 134 135 } while (cPasses-- > 0); 136 137 RTStrFree(pszUser); 138 RTStrFree(pszPassword); 139 RTStrFree(pszDomain); 129 140 } 141
Note:
See TracChangeset
for help on using the changeset viewer.