[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r13603: check return value for crypto_pk_asn1_encode here too. thank (tor/trunk/src/or)
Author: arma
Date: 2008-02-19 18:59:16 -0500 (Tue, 19 Feb 2008)
New Revision: 13603
Modified:
tor/trunk/src/or/rendcommon.c
Log:
check return value for crypto_pk_asn1_encode here too. thanks veracode.
Modified: tor/trunk/src/or/rendcommon.c
===================================================================
--- tor/trunk/src/or/rendcommon.c 2008-02-19 23:57:06 UTC (rev 13602)
+++ tor/trunk/src/or/rendcommon.c 2008-02-19 23:59:16 UTC (rev 13603)
@@ -485,13 +485,18 @@
{
char *cp;
char *end;
- int i;
+ int i, r;
size_t asn1len;
size_t buflen =
PK_BYTES*2*(smartlist_len(desc->intro_nodes)+2);/*Too long, but ok*/
cp = *str_out = tor_malloc(buflen);
end = cp + PK_BYTES*2*(smartlist_len(desc->intro_nodes)+1);
- asn1len = crypto_pk_asn1_encode(desc->pk, cp+2, end-(cp+2));
+ r = crypto_pk_asn1_encode(desc->pk, cp+2, end-(cp+2));
+ if (r < 0) {
+ tor_free(*str_out);
+ return -1;
+ }
+ asn1len = r;
set_uint16(cp, htons((uint16_t)asn1len));
cp += 2+asn1len;
set_uint32(cp, htonl((uint32_t)desc->timestamp));
@@ -509,12 +514,12 @@
cp += strlen(ipoint)+1;
}
note_crypto_pk_op(REND_SERVER);
- i = crypto_pk_private_sign_digest(key, cp, *str_out, cp-*str_out);
- if (i<0) {
+ r = crypto_pk_private_sign_digest(key, cp, *str_out, cp-*str_out);
+ if (r<0) {
tor_free(*str_out);
return -1;
}
- cp += i;
+ cp += r;
*len_out = (size_t)(cp-*str_out);
return 0;
}