diff options
author | Roger Dingledine <arma@torproject.org> | 2002-07-20 01:59:28 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2002-07-20 01:59:28 +0000 |
commit | 1c3b823a82d58f4471b20e64854a82510185d59a (patch) | |
tree | 1f42c301b12c2e9b1f314aced75a1149bd022ab0 | |
parent | 684d50b139531cf81abab66d78e429d5237bce47 (diff) | |
download | tor-1c3b823a82d58f4471b20e64854a82510185d59a.tar tor-1c3b823a82d58f4471b20e64854a82510185d59a.tar.gz |
bugfix: create_onion now works with routelen>2
svn:r66
-rw-r--r-- | src/or/onion.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/or/onion.c b/src/or/onion.c index 52ef72f40..34f1db36a 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -159,8 +159,8 @@ unsigned char *create_onion(routerinfo_t **rarray, size_t rarray_len, unsigned i unsigned char *bufp; routerinfo_t *router; - if ( (rarray) && (route) && (lenp) ) /* valid parameters */ - { + assert(rarray && route && lenp && routelen); + /* calculate the size of the onion */ *lenp = routelen * 28 + 100; /* 28 bytes per layer + 100 bytes padding for the innermost layer */ log(LOG_DEBUG,"create_onion() : Size of the onion is %u.",*lenp); @@ -337,13 +337,10 @@ unsigned char *create_onion(routerinfo_t **rarray, size_t rarray_len, unsigned i log(LOG_DEBUG,"create_onion() : Encrypted layer."); /* calculate pointer to next layer */ - layer = (onion_layer_t *)bufp + (routelen-i-2)*sizeof(onion_layer_t); + layer = (onion_layer_t *)(bufp + (routelen-i-2)*sizeof(onion_layer_t)); } return bufp; - } /* valid parameters */ - else - return NULL; } /* encrypts 128 bytes of the onion with the specified public key, the rest with |