Commit 9151a8a6 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix insertion of bad source in resolver.

parent fb8106c3
......@@ -272,6 +272,10 @@ void belle_sip_main_loop_add_source(belle_sip_main_loop_t *ml, belle_sip_source_
belle_sip_fatal("Source is already linked somewhere else.");
return;
}
if (source->node.data!=source){
belle_sip_fatal("Insane source passed to belle_sip_main_loop_add_source() !");
return;
}
belle_sip_object_ref(source);
if (source->timeout>=0){
source->expire_ms=belle_sip_time_ms()+source->timeout;
......
......@@ -104,9 +104,11 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
if (revents & BELLE_SIP_EVENT_TIMEOUT) {
belle_sip_error("%s timed-out", __FUNCTION__);
ctx->cb(ctx->cb_data, ctx->name, NULL);
ctx->done=TRUE;
return BELLE_SIP_STOP;
}
if (ctx->cancelled) {
ctx->done=TRUE;
return BELLE_SIP_STOP;
}
......@@ -124,8 +126,7 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
if (rr.section == section) {
if ((error = dns_any_parse(dns_any_init(&any, sizeof(any)), &rr, ans))) {
belle_sip_error("%s dns_any_parse error: %s", __FUNCTION__, dns_strerror(error));
free(ans);
return BELLE_SIP_STOP;
break;
}
if ((ctx->family == AF_INET6) && (rr.class == DNS_C_IN) && (rr.type == DNS_T_AAAA)) {
struct dns_aaaa *aaaa = &any.aaaa;
......@@ -137,7 +138,6 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
if (getnameinfo((struct sockaddr *)&sin6, sizeof(sin6), host, sizeof(host), service, sizeof(service), NI_NUMERICHOST) != 0)
continue;
ctx->ai = belle_sip_ip_address_to_addrinfo(ctx->family, host, ctx->port);
ctx->done=TRUE;
belle_sip_message("%s has address %s", ctx->name, host);
break;
} else {
......@@ -151,7 +151,6 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
if (getnameinfo((struct sockaddr *)&sin, sizeof(sin), host, sizeof(host), service, sizeof(service), NI_NUMERICHOST) != 0)
continue;
ctx->ai = belle_sip_ip_address_to_addrinfo(ctx->family, host, ctx->port);
ctx->done=TRUE;
belle_sip_message("%s has address %s", ctx->name, host);
break;
}
......@@ -160,10 +159,12 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
}
free(ans);
ctx->cb(ctx->cb_data, ctx->name, ctx->ai);
ctx->done=TRUE;
return BELLE_SIP_STOP;
}
if (error != DNS_EAGAIN) {
belle_sip_error("%s dns_res_check error: %s (%d)", __FUNCTION__, dns_strerror(error), error);
ctx->done=TRUE;
return BELLE_SIP_STOP;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment