2020-03-26 20:46:02 +00:00
|
|
|
From a1a4730c1f02cd85680cf7608ac81e0db59ee522 Mon Sep 17 00:00:00 2001
|
2019-01-16 16:08:53 +00:00
|
|
|
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
|
|
|
Date: Wed, 16 Jan 2019 16:27:33 +0100
|
2020-03-26 20:46:02 +00:00
|
|
|
Subject: [PATCH] Fix possible crash when loading corrupted file
|
2019-01-16 16:08:53 +00:00
|
|
|
|
|
|
|
Some values passes internal triggers by coincidence. Fix the check and
|
|
|
|
check also first_node_offset before even passing it further.
|
|
|
|
---
|
2020-03-26 20:46:02 +00:00
|
|
|
lib/dns/rbt.c | 6 ++++--
|
|
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
2019-01-16 16:08:53 +00:00
|
|
|
|
|
|
|
diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c
|
2020-03-26 20:46:02 +00:00
|
|
|
index ef6441b..404fd6d 100644
|
2019-01-16 16:08:53 +00:00
|
|
|
--- a/lib/dns/rbt.c
|
|
|
|
+++ b/lib/dns/rbt.c
|
2020-03-26 20:46:02 +00:00
|
|
|
@@ -754,7 +754,7 @@ treefix(dns_rbt_t *rbt, void *base, size_t filesize, dns_rbtnode_t *n,
|
|
|
|
}
|
2019-01-16 16:08:53 +00:00
|
|
|
|
2020-03-26 20:46:02 +00:00
|
|
|
CONFIRM((void *)n >= base);
|
|
|
|
- CONFIRM((char *)n - (char *)base <= (int)nodemax);
|
|
|
|
+ CONFIRM((size_t)((char *)n - (char *)base) <= (int)nodemax);
|
2019-01-16 16:08:53 +00:00
|
|
|
CONFIRM(DNS_RBTNODE_VALID(n));
|
|
|
|
|
|
|
|
dns_name_init(&nodename, NULL);
|
2020-03-26 20:46:02 +00:00
|
|
|
@@ -911,7 +911,9 @@ dns_rbt_deserialize_tree(void *base_address, size_t filesize,
|
|
|
|
rbt->root = (dns_rbtnode_t *)((char *)base_address + header_offset +
|
|
|
|
header->first_node_offset);
|
2019-01-16 16:08:53 +00:00
|
|
|
|
|
|
|
- if ((header->nodecount * sizeof(dns_rbtnode_t)) > filesize) {
|
|
|
|
+ if ((header->nodecount * sizeof(dns_rbtnode_t)) > filesize
|
|
|
|
+ || header->first_node_offset > filesize) {
|
2020-03-26 20:46:02 +00:00
|
|
|
+
|
2019-01-16 16:08:53 +00:00
|
|
|
result = ISC_R_INVALIDFILE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
--
|
2020-03-26 20:46:02 +00:00
|
|
|
2.21.1
|
2019-01-16 16:08:53 +00:00
|
|
|
|