diff options
author | Roger Dingledine <arma@torproject.org> | 2005-01-03 22:35:40 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-01-03 22:35:40 +0000 |
commit | 9e6d6c60962a780954b58becb70cfa6ca89b858d (patch) | |
tree | 8c5d014d19817453d7c07b9ce70e3c27e6e05c05 | |
parent | 53c522ee1ce4b8f769c9328c4bcc886095187ade (diff) | |
download | tor-9e6d6c60962a780954b58becb70cfa6ca89b858d.tar.gz tor-9e6d6c60962a780954b58becb70cfa6ca89b858d.zip |
Bugfix: we've been using openssl's BIO_get_mem_data incorrectly.
We assumed the pem-encoded data written by PEM_write_bio_RSAPrivateKey
is nul-terminated, and at least sometimes, it's not.
svn:r3263
-rw-r--r-- | src/common/crypto.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 104e8a56e9..fc69f7dd1e 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -470,7 +470,8 @@ crypto_pk_write_private_key_to_filename(crypto_pk_env_t *env, len = BIO_get_mem_data(bio, &cp); tor_assert(len >= 0); s = tor_malloc(len+1); - strlcpy(s, cp, len+1); + memcpy(s, cp, len); + s[len]='\0'; r = write_str_to_file(fname, s, 0); BIO_free(bio); free(s); |