Bug 1253706: Stop storing this as a bare pointer. r=mjf

Once we allow the ICE servers to be set, each stream can have a different array
of ICE servers, and those ICE servers can have different lifetimes. Let's avoid
the potential dangling pointer issue here.

Also, this fixes a minor spec violation where we were doing foundation comparison
incorrectly (we're supposed to only compare the address).

Differential Revision: https://phabricator.services.mozilla.com/D135369
This commit is contained in:
Byron Campen [:bwc] 2022-02-08 23:37:57 +00:00
Родитель bd9b8e270e
Коммит 0778b88df0
2 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -377,8 +377,10 @@ static int nr_ice_get_foundation(nr_ice_ctx *ctx,nr_ice_candidate *cand)
// foundation->type should probably match nr_ice_candidate_type
if((int)cand->type != foundation->type)
goto next;
if(cand->stun_server != foundation->stun_server)
goto next;
if(cand->type == SERVER_REFLEXIVE || cand->type == RELAYED) {
if(nr_transport_addr_cmp(&cand->stun_server->addr, &foundation->stun_server_addr, NR_TRANSPORT_ADDR_CMP_MODE_ADDR))
goto next;
}
snprintf(fnd,sizeof(fnd),"%d",i);
if(!(cand->foundation=r_strdup(fnd)))
@ -394,7 +396,9 @@ static int nr_ice_get_foundation(nr_ice_ctx *ctx,nr_ice_candidate *cand)
ABORT(R_NO_MEMORY);
nr_transport_addr_copy(&foundation->addr,&cand->base);
foundation->type=cand->type;
foundation->stun_server=cand->stun_server;
if(cand->type == SERVER_REFLEXIVE || cand->type == RELAYED) {
nr_transport_addr_copy(&foundation->stun_server_addr, &cand->stun_server->addr);
}
STAILQ_INSERT_TAIL(&ctx->foundations,foundation,entry);
snprintf(fnd,sizeof(fnd),"%d",i);

Просмотреть файл

@ -68,7 +68,8 @@ typedef struct nr_ice_foundation_ {
nr_transport_addr addr;
int type;
nr_ice_stun_server *stun_server;
/* ICE spec says that we only compare IP address, not port */
nr_transport_addr stun_server_addr;
STAILQ_ENTRY(nr_ice_foundation_) entry;
} nr_ice_foundation;