Skip to content

Commit

Permalink
Fix hang on unresolvable DNS resolution error.
Browse files Browse the repository at this point in the history
  • Loading branch information
morbit85 committed Sep 6, 2024
1 parent 0a50b84 commit daec4fc
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions libsofia-sip-ua/nta/nta.c
Original file line number Diff line number Diff line change
Expand Up @@ -10085,16 +10085,10 @@ static int outgoing_query_a(nta_outgoing_t *orq, struct sipdns_query *);
static void outgoing_answer_a(sres_context_t *orq, sres_query_t *q,
sres_record_t *answers[]);

#ifdef __clang_analyzer__
#define FUNC_ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
#else
#define FUNC_ATTR_NONNULL(...)
#endif

static void outgoing_query_results(nta_outgoing_t *orq,
struct sipdns_query *sq,
char *results[],
size_t rlen) FUNC_ATTR_NONNULL(3);
size_t rlen);


#define SIPDNS_503_ERROR 503, "DNS Error"
Expand Down Expand Up @@ -10901,7 +10895,7 @@ void outgoing_answer_aaaa(sres_context_t *orq, sres_query_t *q,
else if (found)
results = &result;

for (i = j = 0; results && answers && answers[i]; i++) {
for (i = j = 0; (found > 0) && answers && answers[i]; i++) {
char addr[SU_ADDRSIZE];
sres_aaaa_record_t const *aaaa = answers[i]->sr_aaaa;

Expand All @@ -10923,10 +10917,7 @@ void outgoing_answer_aaaa(sres_context_t *orq, sres_query_t *q,

sres_free_answers(orq->orq_agent->sa_resolver, answers);

if (results)
outgoing_query_results(orq, sq, results, found);
else if (!q)
outgoing_resolving_error(orq, SIPDNS_503_ERROR);
outgoing_query_results(orq, sq, results, found);
}
#endif /* SU_HAVE_IN6 */

Expand Down Expand Up @@ -10987,7 +10978,7 @@ void outgoing_answer_a(sres_context_t *orq, sres_query_t *q,
else if (found)
results = &result;

for (i = j = 0; answers && answers[i]; i++) {
for (i = j = 0; (found > 0) && answers && answers[i]; i++) {
char addr[SU_ADDRSIZE];
sres_a_record_t const *a = answers[i]->sr_a;

Expand All @@ -11008,10 +10999,7 @@ void outgoing_answer_a(sres_context_t *orq, sres_query_t *q,

sres_free_answers(orq->orq_agent->sa_resolver, answers);

if (results)
outgoing_query_results(orq, sq, results, found);
else if (!q)
outgoing_resolving_error(orq, SIPDNS_503_ERROR);
outgoing_query_results(orq, sq, results, found);
}

/** Store A/AAAA query results */
Expand Down

0 comments on commit daec4fc

Please sign in to comment.