Properly respond to wildcard route requests.
authorJennifer Richards <jennifer@painless-security.com>
Thu, 4 Aug 2016 02:26:18 +0000 (22:26 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Thu, 4 Aug 2016 02:26:18 +0000 (22:26 -0400)
tr/tr_trp.c
trp/trp_req.c
trp/trps.c

index 46e4a6e..39e9825 100644 (file)
@@ -542,9 +542,7 @@ static void *tr_trpc_thread(void *arg)
       talloc_free(tmp_ctx);
       return NULL;
     }
-    tr_debug("queuing********************************************************************************");
     trps_mq_add(trps, msg); /* steals msg context */
-    tr_debug("queued********************************************************************************");
     msg=NULL;
 
     while(1) {
index 01c4d58..497acd6 100644 (file)
@@ -91,7 +91,7 @@ void trp_req_set_peer(TRP_REQ *req, TR_NAME *peer)
  * use the empty string. */
 static int trp_req_name_is_wildcard(TR_NAME *name)
 {
-  return (name!=NULL) && (name->len==0) && (name->buf!=NULL) && (name->buf[0]='\0');
+  return (name!=NULL) && (name->len==0);
 }
 
 int trp_req_is_wildcard(TRP_REQ *req)
index 0b1f25d..201935c 100644 (file)
@@ -913,11 +913,6 @@ static TRP_RC trps_update_one_peer(TRPS_INSTANCE *trps,
   TRP_RC rc=TRP_ERROR;
   TRP_PEER *peer=trps_get_peer_by_gssname(trps, peer_gssname);
 
-  if (!trps_peer_connected(trps, peer)) {
-    tr_debug("trps_update_one_peer: no TRP connection to %.*s, skipping.",
-             peer_gssname->len, peer_gssname->buf);
-    goto cleanup;
-  }
   switch (update_type) {
   case TRP_UPDATE_TRIGGERED:
     tr_debug("trps_update_one_peer: preparing triggered route update for %.*s",
@@ -1026,6 +1021,12 @@ TRP_RC trps_update(TRPS_INSTANCE *trps, TRP_UPDATE_TYPE update_type)
        peer!=NULL && rc==TRP_SUCCESS;
        peer=trp_ptable_iter_next(iter))
   {
+    if (!trps_peer_connected(trps, peer)) {
+      TR_NAME *peer_gssname=trp_peer_get_gssname(peer);
+      tr_debug("trps_update: no TRP connection to %.*s, skipping.",
+               peer_gssname->len, peer_gssname->buf);
+      continue;
+    }
     rc=trps_update_one_peer(trps, trp_peer_get_gssname(peer), update_type, NULL, NULL);
   }
   
@@ -1089,6 +1090,7 @@ static TRP_RC trps_handle_request(TRPS_INSTANCE *trps, TRP_REQ *req)
              comm->len, comm->buf, realm->len, realm->buf);
   } else {
     tr_debug("trps_handle_request: all routes requested.");
+    /* leave comm/realm NULL */
   }
   return trps_update_one_peer(trps, trp_req_get_peer(req), TRP_UPDATE_REQUESTED, comm, realm);
 }