Changeset 42231 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 19, 2012 3:22:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r42212 r42231 2133 2133 if (RT_SUCCESS(rc)) 2134 2134 { 2135 /* check if this is really a Null-terminated string. */2136 2135 for (unsigned i = 0; i < cbCiphertext; i++) 2137 2136 { 2137 /* sanity check: null-terminated string? */ 2138 2138 if (abPlaintext[i] == '\0') 2139 2139 { 2140 *aPlaintext = Utf8Str((const char*)abPlaintext); 2141 return VINF_SUCCESS; 2140 /* sanity check: valid UTF8 string? */ 2141 if (RTStrIsValidEncoding((const char*)abPlaintext)) 2142 { 2143 *aPlaintext = Utf8Str((const char*)abPlaintext); 2144 return VINF_SUCCESS; 2145 } 2142 2146 } 2143 2147 } 2144 rc = VERR_INVALID_ PARAMETER;2148 rc = VERR_INVALID_MAGIC; 2145 2149 } 2146 2150 } … … 2168 2172 return VERR_BUFFER_OVERFLOW; 2169 2173 2170 for (i = 0, j = 0; i < aPlaintextSize && i < aCiphertextSize; i++) 2171 { 2172 aCiphertext[i] = (aPlaintext[i] ^ m->SettingsCipherKey[j]); 2174 if (aCiphertextSize < 32) 2175 return VERR_INVALID_PARAMETER; 2176 2177 AssertCompile(sizeof(m->SettingsCipherKey) >= 32); 2178 2179 /* store the first 8 bytes of the cipherkey for verification */ 2180 for (i = 0, j = 0; i < 8; i++, j++) 2181 aCiphertext[i] = m->SettingsCipherKey[j]; 2182 2183 for (unsigned k = 0; k < aPlaintextSize && i < aCiphertextSize; i++, k++) 2184 { 2185 aCiphertext[i] = (aPlaintext[k] ^ m->SettingsCipherKey[j]); 2173 2186 if (++j >= sizeof(m->SettingsCipherKey)) 2174 2187 j = 0; … … 2200 2213 const uint8_t *aCiphertext, size_t aCiphertextSize) const 2201 2214 { 2215 unsigned i, j; 2216 2202 2217 if (!m->fSettingsCipherKeySet) 2203 2218 return VERR_INVALID_STATE; 2204 2219 2205 for (unsigned i = 0, j = 0; i < aCiphertextSize; i++) 2206 { 2207 aPlaintext[i] = aCiphertext[i] ^ m->SettingsCipherKey[j]; 2220 if (aCiphertextSize < 32) 2221 return VERR_INVALID_PARAMETER; 2222 2223 /* key verification */ 2224 for (i = 0, j = 0; i < 8; i++, j++) 2225 if (aCiphertext[i] != m->SettingsCipherKey[j]) 2226 return VERR_INVALID_MAGIC; 2227 2228 /* poison */ 2229 memset(aPlaintext, 0xff, aCiphertextSize); 2230 for (int k = 0; i < aCiphertextSize; i++, k++) 2231 { 2232 aPlaintext[k] = aCiphertext[i] ^ m->SettingsCipherKey[j]; 2208 2233 if (++j >= sizeof(m->SettingsCipherKey)) 2209 2234 j = 0;
Note:
See TracChangeset
for help on using the changeset viewer.