diff options
author | Roger Dingledine <arma@torproject.org> | 2008-02-19 23:59:16 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2008-02-19 23:59:16 +0000 |
commit | e0beb6cc5ec69631645e82db67174c431f4c7563 (patch) | |
tree | 8f82da586f821a36b96bfd046501e9654c889e1a /src/or/rendcommon.c | |
parent | 260c37c14c75ca869c04da9837b533b8b250a06b (diff) | |
download | tor-e0beb6cc5ec69631645e82db67174c431f4c7563.tar.gz tor-e0beb6cc5ec69631645e82db67174c431f4c7563.zip |
check return value for crypto_pk_asn1_encode here too. thanks veracode.
svn:r13603
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r-- | src/or/rendcommon.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 2cb7c9d798..5f7d6cc004 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -485,13 +485,18 @@ rend_encode_service_descriptor(rend_service_descriptor_t *desc, { 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 @@ rend_encode_service_descriptor(rend_service_descriptor_t *desc, 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; } |