diff options
author | Corey Farrell <git@cfware.com> | 2017-12-18 23:48:52 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2017-12-19 14:50:11 -0500 |
commit | b8f54f742f1b5b14fb21fdc66cab815efec34640 (patch) | |
tree | aedf4366b63ac840f9b276b6d12d130beed85669 | |
parent | a100baccb54f8a43b74f2241fe06f5efb326bab0 (diff) |
dns_core: Protect against array index violation.
Add a check to allocate_dns_record to prevent calling a pointer
retrieved from beyond dns_alloc_table.
ASTERISK-27495 #close
Change-Id: Ie2f6e4991cea46baa12e837bd64cc22b44d322bb
-rw-r--r-- | main/dns_core.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/main/dns_core.c b/main/dns_core.c index a243b4bdd..3e270aff7 100644 --- a/main/dns_core.c +++ b/main/dns_core.c @@ -447,9 +447,13 @@ static dns_alloc_fn dns_alloc_table [] = { [T_SRV] = dns_srv_alloc, }; -static struct ast_dns_record *allocate_dns_record(int rr_type, struct ast_dns_query *query, const char *data, const size_t size) +static struct ast_dns_record *allocate_dns_record(unsigned int rr_type, struct ast_dns_query *query, const char *data, const size_t size) { - dns_alloc_fn allocator = dns_alloc_table[rr_type] ?: generic_record_alloc; + dns_alloc_fn allocator = generic_record_alloc; + + if (rr_type < ARRAY_LEN(dns_alloc_table) && dns_alloc_table[rr_type]) { + allocator = dns_alloc_table[rr_type]; + } return allocator(query, data, size); } |