[or-cvs] bugfix: make onions work again

Roger Dingledine arma at seul.org
Wed Apr 16 17:07:48 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home/arma/work/onion/cvs/src/or

Modified Files:
	onion.c 
Log Message:
bugfix: make onions work again


Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- onion.c	16 Apr 2003 16:19:27 -0000	1.34
+++ onion.c	16 Apr 2003 17:07:46 -0000	1.35
@@ -496,7 +496,7 @@
     layer.expire = (uint32_t)(time(NULL) + 86400); /* NOW + 1 day */
   
     /* Key Seed Material */
-    if(crypto_rand(16, layer.keyseed)) { /* error */
+    if(crypto_rand(ONION_KEYSEED_LEN, layer.keyseed)) { /* error */
       log(LOG_ERR,"Error generating random data.");
       goto error;
     }
@@ -678,7 +678,7 @@
   }
   log(LOG_DEBUG,"decrypt_onion() : RSA decryption complete.");
     
-  onion_unpack(layer, onion);
+  onion_unpack(layer, tmpbuf);
 
   /* get key1 = SHA1(KeySeed) */
   if (crypto_SHA_digest(layer->keyseed,16,digest)) {
@@ -791,7 +791,7 @@
   
   /* this is a new onion. add it to the list. */
 
-  to->expire = ntohl(*(uint32_t *)(onion+8)); /* set the expiration date */
+  to->expire = ntohl(*(uint32_t *)(onion+7)); /* set the expiration date */
   to->next = NULL;
 
   if (!head_tracked_onions) {
@@ -811,11 +811,13 @@
 {
   assert((src->version & 0x80) == 0);
   
-  *(uint8_t*)dest = src->version;
+  *(uint8_t*)(dest) = src->version;
   *(uint16_t*)(dest+1) = htons(src->port);
   *(uint32_t*)(dest+3) = htonl(src->addr);
   *(uint32_t*)(dest+7) = htonl(src->expire);
   memcpy(dest+11, src->keyseed, ONION_KEYSEED_LEN);
+  log(LOG_DEBUG,"onion_pack(): version %d, port %d, addr %s, expire %u", src->version, src->port,
+    inet_ntoa(*((struct in_addr *)(dest+3))), src->expire);
 }
 
 void
@@ -826,6 +828,9 @@
   dest->addr = ntohl(*(uint32_t*)(src+3));
   dest->expire = ntohl(*(uint32_t*)(src+7));
   memcpy(dest->keyseed, src+11, ONION_KEYSEED_LEN);
+
+  log(LOG_DEBUG,"onion_unpack(): version %d, port %d, addr %s, expire %u", dest->version, dest->port,
+    inet_ntoa(*((struct in_addr *)(src+3))), dest->expire);
 }
 
 /*



More information about the tor-commits mailing list