[or-cvs] Support new INTRODUCE2 cell format

Nick Mathewson nickm at seul.org
Wed Aug 18 04:49:02 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv23297/src/or

Modified Files:
	rendservice.c 
Log Message:
Support new INTRODUCE2 cell format

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- rendservice.c	17 Aug 2004 06:27:32 -0000	1.79
+++ rendservice.c	18 Aug 2004 04:48:59 -0000	1.80
@@ -354,6 +354,8 @@
   crypt_path_t *cpath = NULL;
   char serviceid[REND_SERVICE_ID_LEN+1];
   char hexcookie[9];
+  int version;
+  int nickname_field_len;
 
   base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
                 circuit->rend_pk_digest,10);
@@ -367,7 +369,7 @@
   }
 
   /* min key length plus digest length plus nickname length */
-  if (request_len < DIGEST_LEN+REND_COOKIE_LEN+(MAX_NICKNAME_LEN+1)+
+  if (request_len < DIGEST_LEN+REND_COOKIE_LEN+(HEX_DIGEST_LEN+2)+
       DH_KEY_LEN+42){
     log_fn(LOG_WARN, "Got a truncated INTRODUCE2 cell on circ %d",
            circuit->n_circ_id);
@@ -401,19 +403,29 @@
     log_fn(LOG_WARN, "Couldn't decrypt INTRODUCE2 cell");
     return -1;
   }
-  ptr=memchr(buf,0,MAX_NICKNAME_LEN+1);
-  if (!ptr || ptr == buf) {
+  if (*buf == 1) {
+    rp_nickname = buf+1;
+    nickname_field_len = HEX_DIGEST_LEN+2;
+    version = 1;
+  } else {
+    nickname_field_len = MAX_NICKNAME_LEN+1;
+    rp_nickname = buf;
+    version = 0;
+  }
+  ptr=memchr(rp_nickname,0,nickname_field_len);
+  if (!ptr || ptr == rp_nickname) {
     log_fn(LOG_WARN, "Couldn't find a null-padded nickname in INTRODUCE2 cell");
     return -1;
   }
-  if ((int)strspn(buf,LEGAL_NICKNAME_CHARACTERS) != ptr-buf) {
-    log_fn(LOG_WARN, "Nickname in INTRODUCE2 cell contains illegal character.");
+  if ((version == 0 && !is_legal_nickname(rp_nickname)) ||
+      (version == 1 && !is_legal_nickname_or_hexdigest(rp_nickname)) ||
+      (int)strspn(buf,LEGAL_NICKNAME_CHARACTERS) != ptr-buf) {
+    log_fn(LOG_WARN, "Bad nickname in INTRODUCE2 cell.");
     return -1;
   }
-  /* Okay, now we know that the nickname is at the start of the buffer. */
-  rp_nickname = buf;
-  ptr = buf+(MAX_NICKNAME_LEN+1);
-  len -= (MAX_NICKNAME_LEN+1);
+  /* Okay, now we know that a nickname is at the start of the buffer. */
+  ptr = rp_nickname+nickname_field_len;
+  len -= nickname_field_len;
   if (len != REND_COOKIE_LEN+DH_KEY_LEN) {
     log_fn(LOG_WARN, "Bad length for INTRODUCE2 cell.");
     return -1;



More information about the tor-commits mailing list