[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] i2d_RSAPublicKey advances the pointer it receives past the ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] i2d_RSAPublicKey advances the pointer it receives past the ...
- From: nickm@seul.org (Nick Mathewson)
- Date: Mon, 5 Apr 2004 13:10:50 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Mon, 05 Apr 2004 13:11:07 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv8493/src/common
Modified Files:
crypto.c
Log Message:
i2d_RSAPublicKey advances the pointer it receives past the ASN1-encoded string.
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- crypto.c 3 Apr 2004 04:05:11 -0000 1.69
+++ crypto.c 5 Apr 2004 17:10:48 -0000 1.70
@@ -638,12 +638,12 @@
int crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, int dest_len)
{
int len;
- unsigned char *buf, *bufp;
+ unsigned char *buf, *cp;
len = i2d_RSAPublicKey(pk->key, NULL);
if (len < 0 || len > dest_len)
return -1;
- bufp = buf = tor_malloc(len+1);
- len = i2d_RSAPublicKey(pk->key, &bufp);
+ cp = buf = tor_malloc(len+1);
+ len = i2d_RSAPublicKey(pk->key, &cp);
if (len < 0) {
tor_free(buf);
return -1;
@@ -662,17 +662,17 @@
{
RSA *rsa;
unsigned char *buf;
- const unsigned char *bufp;
- bufp = buf = tor_malloc(len);
- memcpy(buf,str,len);
/* This ifdef suppresses a type warning. Take out the first case once
* everybody is using openssl 0.9.7 or later.
*/
#if OPENSSL_VERSION_NUMBER < 0x00907000l
- rsa = d2i_RSAPublicKey(NULL, &buf, len);
+ unsigned char *cp;
#else
- rsa = d2i_RSAPublicKey(NULL, &bufp, len);
+ const unsigned char *cp;
#endif
+ cp = buf = tor_malloc(len);
+ memcpy(buf,str,len);
+ rsa = d2i_RSAPublicKey(NULL, &cp, len);
tor_free(buf);
if (!rsa)
return NULL; /* XXXX log openssl error */