summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-02-07 18:01:03 +0000
committerJoshua Colp <jcolp@digium.com>2017-02-07 12:13:23 -0600
commit5422ec140c274a3bad651401db7c82938275b18b (patch)
tree177593df32b06f3a65b8cf59306df289845309d2
parentb47cf1a7d6aba11b145b14883e8c607362756001 (diff)
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.
When performing an SRV lookup using the ast_srv_lookup function it did not properly handle the situation where 0 records are returned. If this happened it would wrongly assume that at least one record was present. This change fixes the code so it will exit early if an error occurs or if 0 records are returned. ASTERISK-26772 patches: srv_lookup.patch submitted by nappsoft (license 6822) Change-Id: I09b19081c74e0ad11c12bf54a257243b1bcb2351
-rw-r--r--main/srv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/main/srv.c b/main/srv.c
index ef073a517..cedad7363 100644
--- a/main/srv.c
+++ b/main/srv.c
@@ -209,7 +209,8 @@ int ast_srv_lookup(struct srv_context **context, const char *service, const char
}
AST_LIST_HEAD_INIT_NOLOCK(&(*context)->entries);
- if ((ast_search_dns(*context, service, C_IN, T_SRV, srv_callback)) < 0) {
+ if (((ast_search_dns(*context, service, C_IN, T_SRV, srv_callback)) < 1) ||
+ AST_LIST_EMPTY(&(*context)->entries)) {
ast_free(*context);
*context = NULL;
return -1;