2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

check chain length is nonzero before examining last entry

It was possible to reach add_link() without visiting an
intermediate node first, and the check for a duplicate entry
could then cause a crash.

Credit to OSS-Fuzz for discovering this error.
This commit is contained in:
Evan Hunt
2023-10-11 11:03:00 -07:00
parent a87436d3d5
commit 3a206da456

View File

@@ -1997,7 +1997,7 @@ dns_qp_getname(dns_qpreadable_t qpr, const dns_name_t *name, void **pval_r,
static inline void
add_link(dns_qpchain_t *chain, dns_qpnode_t *node, size_t offset) {
/* prevent duplication */
if (chain->chain[chain->len - 1].node == node) {
if (chain->len != 0 && chain->chain[chain->len - 1].node == node) {
return;
}
chain->chain[chain->len].node = node;