[or-cvs] Bugfix: we"ve been using openssl"s BIO_get_mem_data incorre...
Roger Dingledine
arma at seul.org
Mon Jan 3 22:35:43 UTC 2005
Update of /home2/or/cvsroot/tor/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/common
Modified Files:
crypto.c
Log Message:
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.
Index: crypto.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- crypto.c 13 Dec 2004 18:38:19 -0000 1.130
+++ crypto.c 3 Jan 2005 22:35:40 -0000 1.131
@@ -470,7 +470,8 @@
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);
More information about the tor-commits
mailing list