[Asterisk-code-review] dundi: fix NULL dereference. (asterisk[master])

Jaco Kroon asteriskteam at digium.com
Wed Mar 18 04:39:00 CDT 2020


Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13948 )


Change subject: dundi:  fix NULL dereference.
......................................................................

dundi:  fix NULL dereference.

If a negative (error) return is received from dundi_lookup_internal,
this is not handled correctly when assigning the result to the buffer.
As such, use a signed integer in the assignment and do a proper
comparison.

ASTERISK-21205

Change-Id: I5214ebb6491e2bd14f90c7d3ce229da86888f739
---
M pbx/pbx_dundi.c
1 file changed, 3 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/48/13948/1

diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 6cc7711..adb80f5 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -4193,7 +4193,7 @@
 
 struct dundi_result_datastore {
 	struct dundi_result results[MAX_RESULTS];
-	unsigned int num_results;
+	int num_results;
 	unsigned int id;
 };
 
@@ -4325,7 +4325,7 @@
 	drds = datastore->data;
 
 	if (!strcasecmp(args.resultnum, "getnum")) {
-		snprintf(buf, len, "%u", drds->num_results);
+		snprintf(buf, len, "%u", drds->num_results < 0 ? 0 : drds->num_results);
 		res = 0;
 		goto finish;
 	}
@@ -4336,7 +4336,7 @@
 		goto finish;
 	}
 
-	if (num && num <= drds->num_results) {
+	if (num && drds->num_results > 0 && num <= drds->num_results) {
 		snprintf(buf, len, "%s/%s", drds->results[num - 1].tech, drds->results[num - 1].dest);
 		res = 0;
 	} else

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13948
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I5214ebb6491e2bd14f90c7d3ce229da86888f739
Gerrit-Change-Number: 13948
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200318/048b40d2/attachment.html>


More information about the asterisk-code-review mailing list