]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Bugfix: we've been using openssl's BIO_get_mem_data incorrectly.
authorRoger Dingledine <arma@torproject.org>
Mon, 3 Jan 2005 22:35:40 +0000 (22:35 +0000)
committerRoger Dingledine <arma@torproject.org>
Mon, 3 Jan 2005 22:35:40 +0000 (22:35 +0000)
We assumed the pem-encoded data written by PEM_write_bio_RSAPrivateKey
is nul-terminated, and at least sometimes, it's not.

svn:r3263

src/common/crypto.c

index 104e8a56e9bfa783f25fe2476628b001999aaf23..fc69f7dd1e6dd12441fdcf1902a04f83bcd7d337 100644 (file)
@@ -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);