[asterisk-commits] srv: Fix crash when ast srv lookup is used and 0 records are... (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 8 10:15:42 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4898 )

Change subject: srv: Fix crash when ast_srv_lookup is used and 0 records are returned.
......................................................................


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
---
M main/srv.c
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified



diff --git a/main/srv.c b/main/srv.c
index c079749..e2dfb2b 100644
--- a/main/srv.c
+++ b/main/srv.c
@@ -211,7 +211,8 @@
 		}
 		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;

-- 
To view, visit https://gerrit.asterisk.org/4898
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I09b19081c74e0ad11c12bf54a257243b1bcb2351
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list