aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendcommon.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2010-02-23 17:09:02 +0100
committerSebastian Hahn <sebastian@torproject.org>2010-02-26 05:49:34 +0100
commitf36c36f4a881d15d2187efbc59becb5195d0bf09 (patch)
treee1569060750e5b86eefc0ec033182ca39ed4d6cd /src/or/rendcommon.c
parenta9802d3322f14e9649cbec354ffcf7e1cf266494 (diff)
downloadtor-f36c36f4a881d15d2187efbc59becb5195d0bf09.tar
tor-f36c36f4a881d15d2187efbc59becb5195d0bf09.tar.gz
Proper NULL checking for hsdesc publication
Fix a dereference-then-NULL-check sequence. This bug wasn't triggered in the wild, but we should fix it anyways in case it ever happens. Also make sure users get a note about this being a bug when they see it in their log. Thanks to ekir for discovering and reporting this bug.
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r--src/or/rendcommon.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index d21eb42ef..a625900cd 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -451,17 +451,17 @@ rend_encode_v2_descriptors(smartlist_t *descs_out,
size_t ipos_len = 0, ipos_encrypted_len = 0;
int k;
uint32_t seconds_valid;
- crypto_pk_env_t *service_key = auth_type == REND_STEALTH_AUTH ?
- client_key : desc->pk;
+ crypto_pk_env_t *service_key;
+ if (!desc) {
+ log_warn(LD_BUG, "Could not encode v2 descriptor: No desc given.");
+ return -1;
+ }
+ service_key = (auth_type == REND_STEALTH_AUTH) ? client_key : desc->pk;
tor_assert(service_key);
if (auth_type == REND_STEALTH_AUTH) {
descriptor_cookie = smartlist_get(client_cookies, 0);
tor_assert(descriptor_cookie);
}
- if (!desc) {
- log_warn(LD_REND, "Could not encode v2 descriptor: No desc given.");
- return -1;
- }
/* Obtain service_id from public key. */
crypto_pk_get_digest(service_key, service_id);
/* Calculate current time-period. */