2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 07:35:26 +00:00

skip if first is NULL

This commit is contained in:
Mark Andrews
2020-01-30 18:55:36 +11:00
committed by Ondřej Surý
parent c65c06301c
commit 704b9ee9d0

View File

@@ -1122,7 +1122,7 @@ free_element_heap(void *element, void *uap) {
} }
static bool static bool
checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first, _checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first,
const struct nsec3_chain_fixed *e) const struct nsec3_chain_fixed *e)
{ {
char buf[512]; char buf[512];
@@ -1162,6 +1162,37 @@ checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first,
return (false); return (false);
} }
static inline bool
checknext(isc_mem_t *mctx,
const vctx_t *vctx,
const struct nsec3_chain_fixed *first,
struct nsec3_chain_fixed *prev,
const struct nsec3_chain_fixed *cur)
{
bool result = _checknext(vctx, prev, cur);
if (prev != first) {
free_element(mctx, prev);
}
return (result);
}
static inline bool
checklast(isc_mem_t *mctx,
const vctx_t *vctx,
struct nsec3_chain_fixed *first,
struct nsec3_chain_fixed *prev)
{
bool result = _checknext(vctx, prev, first);
if (prev != first) {
free_element(mctx, prev);
}
free_element(mctx, first);
return (result);
}
static isc_result_t static isc_result_t
verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) { verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) {
isc_result_t result = ISC_R_SUCCESS; isc_result_t result = ISC_R_SUCCESS;
@@ -1214,39 +1245,27 @@ verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) {
"not equal"); "not equal");
result = ISC_R_FAILURE; result = ISC_R_FAILURE;
} }
if (first == NULL || newchain(first, e)) {
if (prev != NULL) { if (first == NULL) {
if (!checknext(vctx, prev, first)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
}
if (first != NULL) {
free_element(mctx, first);
}
prev = first = e; prev = first = e;
continue; } else if (newchain(first, e)) {
if (!checklast(mctx, vctx, first, prev)) {
result = ISC_R_FAILURE;
}
prev = first = e;
} else {
if (!checknext(mctx, vctx, first, prev, e)) {
result = ISC_R_FAILURE;
}
prev = e;
} }
if (!checknext(vctx, prev, e)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
prev = e;
} }
if (prev != NULL) { if (prev != NULL) {
if (!checknext(vctx, prev, first)) { if (!checklast(mctx, vctx, first, prev)) {
result = ISC_R_FAILURE; result = ISC_R_FAILURE;
} }
if (prev != first) {
free_element(mctx, prev);
}
}
if (first != NULL) {
free_element(mctx, first);
} }
do { do {
if (f != NULL) { if (f != NULL) {