[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Coalesce v0 and v1 fields of rend_intro_cell_t



commit ac632a784cdeecaef81e5f1fe45a20f43a93aea7
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Dec 30 12:07:28 2014 -0500

    Coalesce v0 and v1 fields of rend_intro_cell_t
    
    This saves a tiny bit of code, and makes a longstanding coverity
    false positive go away.
---
 src/or/rendservice.c |    9 ++-------
 src/or/rendservice.h |    6 +-----
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 196145e..d4fbe73 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -1527,8 +1527,7 @@ find_rp_for_intro(const rend_intro_cell_t *intro,
   }
 
   if (intro->version == 0 || intro->version == 1) {
-    if (intro->version == 1) rp_nickname = (const char *)(intro->u.v1.rp);
-    else rp_nickname = (const char *)(intro->u.v0.rp);
+    rp_nickname = (const char *)(intro->u.v0_v1.rp);
 
     node = node_get_by_nickname(rp_nickname, 0);
     if (!node) {
@@ -1777,11 +1776,7 @@ rend_service_parse_intro_for_v0_or_v1(
     goto err;
   }
 
-  if (intro->version == 1) {
-    memcpy(intro->u.v1.rp, rp_nickname, endptr - rp_nickname + 1);
-  } else {
-    memcpy(intro->u.v0.rp, rp_nickname, endptr - rp_nickname + 1);
-  }
+  memcpy(intro->u.v0_v1.rp, rp_nickname, endptr - rp_nickname + 1);
 
   return ver_specific_len;
 
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index c2342ef..05502ca 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -38,13 +38,9 @@ struct rend_intro_cell_s {
   /* Version-specific parts */
   union {
     struct {
-      /* Rendezvous point nickname */
-      uint8_t rp[20];
-    } v0;
-    struct {
       /* Rendezvous point nickname or hex-encoded key digest */
       uint8_t rp[42];
-    } v1;
+    } v0_v1;
     struct {
       /* The extend_info_t struct has everything v2 uses */
       extend_info_t *extend_info;

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits