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
This commit is contained in:
Jaco Kroon 2020-03-18 11:38:30 +02:00 committed by Kevin Harwell
parent 34750d2068
commit 40e93b0240
1 changed files with 3 additions and 3 deletions

View File

@ -4193,7 +4193,7 @@ static unsigned int dundi_result_id;
struct dundi_result_datastore {
struct dundi_result results[MAX_RESULTS];
unsigned int num_results;
int num_results;
unsigned int id;
};
@ -4325,7 +4325,7 @@ static int dundi_result_read(struct ast_channel *chan, const char *cmd, char *da
drds = datastore->data;
if (!strcasecmp(args.resultnum, "getnum")) {
snprintf(buf, len, "%u", drds->num_results);
snprintf(buf, len, "%d", drds->num_results < 0 ? 0 : drds->num_results);
res = 0;
goto finish;
}
@ -4336,7 +4336,7 @@ static int dundi_result_read(struct ast_channel *chan, const char *cmd, char *da
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