Skip to content

Commit

Permalink
core: dns - safety checks for port and proto pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Jul 18, 2017
1 parent 65593cc commit febccd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/core/dns_cache.c
Expand Up @@ -2560,7 +2560,7 @@ struct hostent* dns_srv_get_he(str* name, unsigned short* port, int flags)
rr_name.len=((struct srv_rdata*)rr->rdata)->name_len;
if ((he=dns_get_he(&rr_name, flags))!=0){
/* success, at least one good ip found */
*port=((struct srv_rdata*)rr->rdata)->port;
if(port) *port=((struct srv_rdata*)rr->rdata)->port;
goto end;
}
rr_no++; /* try from the next record, the current one was not good */
Expand Down Expand Up @@ -3213,9 +3213,9 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h, str* name,
int ret;
struct hostent* he;
size_t i,list_len;
char origproto;
char origproto = 0;

origproto = *proto;
if(proto) origproto = *proto;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LM_WARN("called before dns cache initialization\n");
h->srv=h->a=0;
Expand Down Expand Up @@ -3344,7 +3344,7 @@ inline static int dns_naptr_sip_resolve(struct dns_srv_handle* h, str* name,
int ret;

ret=-E_DNS_NO_NAPTR;
origproto=*proto;
if(proto) origproto=*proto;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LM_WARN("called before dns cache initialization\n");
h->srv=h->a=0;
Expand Down Expand Up @@ -3399,7 +3399,7 @@ inline static int dns_naptr_sip_resolve(struct dns_srv_handle* h, str* name,
from previous dns_srv_sip_resolve calls */
}
naptr_not_found:
*proto=origproto;
if(proto) *proto=origproto;
return dns_srv_sip_resolve(h, name, ip, port, proto, flags);
}
#endif /* USE_NAPTR */
Expand Down
4 changes: 2 additions & 2 deletions src/core/resolve.c
Expand Up @@ -1597,7 +1597,7 @@ struct hostent* naptr_sip_resolvehost(str* name, unsigned short* port,
naptr_bmp_t tried_bmp; /* tried bitmap */
char origproto;

origproto = *proto;
if(proto) origproto = *proto;
naptr_head=0;
he=0;
if (name->len >= MAX_DNS_NAME) {
Expand Down Expand Up @@ -1634,7 +1634,7 @@ struct hostent* naptr_sip_resolvehost(str* name, unsigned short* port,
#endif
}
/* fallback to srv lookup */
*proto = origproto;
if(proto) *proto = origproto;
he=no_naptr_srv_sip_resolvehost(name,port,proto);
/* fallback all the way down to A/AAAA */
if (he==0) {
Expand Down

0 comments on commit febccd6

Please sign in to comment.