[Asterisk-code-review] dns core: Protect against array index violation. (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Tue Dec 19 10:24:47 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7664
Change subject: dns_core: Protect against array index violation.
......................................................................
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
---
M main/dns_core.c
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/64/7664/1
diff --git a/main/dns_core.c b/main/dns_core.c
index a243b4b..8ce8b9f 100644
--- a/main/dns_core.c
+++ b/main/dns_core.c
@@ -449,7 +449,11 @@
static struct ast_dns_record *allocate_dns_record(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);
}
--
To view, visit https://gerrit.asterisk.org/7664
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2f6e4991cea46baa12e837bd64cc22b44d322bb
Gerrit-Change-Number: 7664
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171219/1ce58888/attachment.html>
More information about the asterisk-code-review
mailing list