diff options
author | Jenkins2 <jenkins2@gerrit.asterisk.org> | 2017-12-20 08:00:29 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-12-20 08:00:29 -0600 |
commit | a711ac25f1b6364552aa4fd09d1a16d303fd28f1 (patch) | |
tree | a3f644649cf7f26247ca3ea96fa1ebc803854cf2 | |
parent | 78fb99e5a30b6301bc17da966f0f8007ae091975 (diff) | |
parent | b8f54f742f1b5b14fb21fdc66cab815efec34640 (diff) |
Merge "dns_core: Protect against array index violation."
-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); } |