Skip to content

Commit dad97a9

Browse files
authored
XDB-478 fix for clearing pw (#211)
1 parent 4d73e66 commit dad97a9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

flow/PKey.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ StringRef PrivateKey::writePemWithPassword(Arena& arena, StringRef password) con
244244
auto mem = AutoCPointer(::BIO_new(::BIO_s_mem()), &::BIO_free);
245245
if (!mem)
246246
traceAndThrowEncode("PrivateKeyPemWriteInitError");
247+
std::vector<unsigned char> pwBytes(password.begin(), password.end());
247248
if (1 !=
248249
::PEM_write_bio_PrivateKey(mem,
249250
nativeHandle(),
250251
::EVP_aes_256_cbc(),
251-
const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(password.begin())),
252-
password.size(),
252+
pwBytes.data(),
253+
pwBytes.size(),
253254
0,
254255
nullptr))
255256
traceAndThrowEncode("PrivateKeyPemWithPasswordWrite");

0 commit comments

Comments
 (0)