Bug 1189198: don't start STUN transactions with a protocol mis-match draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Thu, 30 Jul 2015 00:48:28 -0700
changeset 282095 689a1bfaad31f828275ec690c9bd9928f038d456
parent 281889 62469b20ec842c2399c409bdc2af0f5e5d3facd2
child 507912 6de7489c7f6219a8b85c0c5b7126afb399d43940
push id3940
push userdrno@ohlmeier.org
push dateFri, 31 Jul 2015 02:47:31 +0000
bugs1189198
milestone42.0a1
Bug 1189198: don't start STUN transactions with a protocol mis-match
media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.c
--- a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
@@ -549,18 +549,18 @@ int nr_ice_candidate_initialize(nr_ice_c
       case RELAYED:
         protocol=NR_RESOLVE_PROTOCOL_TURN;
         /* Fall through */
 #endif
       case SERVER_REFLEXIVE:
         cand->state=NR_ICE_CAND_STATE_INITIALIZING;
 
         if(cand->stun_server->type == NR_ICE_STUN_SERVER_TYPE_ADDR) {
-          if(cand->base.ip_version != cand->stun_server->u.addr.ip_version) {
-            r_log(LOG_ICE, LOG_INFO, "ICE-CANDIDATE(%s): Skipping srflx/relayed candidate with different IP version (%u) than STUN/TURN server (%u).", cand->label,cand->base.ip_version,cand->stun_server->u.addr.ip_version);
+          if(nr_transport_addr_cmp(&cand->base,&cand->stun_server->u.addr,NR_TRANSPORT_ADDR_CMP_MODE_PROTOCOL)) {
+            r_log(LOG_ICE, LOG_INFO, "ICE-CANDIDATE(%s): Skipping srflx/relayed candidate because of IP version/transport mis-match with STUN/TURN server (%u/%u - %u/%u).", cand->label,cand->base.ip_version,cand->base.protocol,cand->stun_server->u.addr.ip_version,cand->stun_server->u.addr.protocol);
             ABORT(R_NOT_FOUND); /* Same error code when DNS lookup fails */
           }
 
           /* Just copy the address */
           if (r=nr_transport_addr_copy(&cand->stun_server_addr,
                                        &cand->stun_server->u.addr)) {
             r_log(LOG_ICE,LOG_ERR,"ICE-CANDIDATE(%s): Could not copy STUN server addr", cand->label);
             ABORT(r);
--- a/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.c
@@ -375,16 +375,18 @@ static int nr_stun_client_send_request(n
     if (ctx->request->length == 0) {
         if ((r=nr_stun_encode_message(ctx->request)))
             ABORT(r);
     }
 
     snprintf(string, sizeof(string)-1, "STUN-CLIENT(%s): Sending to %s ", ctx->label, ctx->peer_addr.as_string);
     r_dump(NR_LOG_STUN, LOG_DEBUG, string, (char*)ctx->request->buffer, ctx->request->length);
 
+    assert(ctx->my_addr.protocol==ctx->peer_addr.protocol);
+
     if(r=nr_socket_sendto(ctx->sock, ctx->request->buffer, ctx->request->length, 0, &ctx->peer_addr))
       ABORT(r);
 
     ctx->request_ct++;
 
     if (NR_STUN_GET_TYPE_CLASS(ctx->request->header.type) == NR_CLASS_INDICATION) {
         /* no need to set the timer because indications don't receive a
          * response */