]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix possible NULL dereference in `cfg_map_findclause()`
authorColin Vidal <colin@isc.org>
Tue, 19 May 2026 13:04:11 +0000 (15:04 +0200)
committerColin Vidal <colin@isc.org>
Thu, 21 May 2026 14:04:01 +0000 (16:04 +0200)
`cfg_map_findclause()` did not check whether a clause existed before
dereferencing it, which could lead to a NULL dereference. Add the
missing check to prevent this.

In practice, this was not triggering any known bug, since
`cfg_map_findclause()` is only called in contexts where the clause is
known to exist.

lib/isccfg/parser.c

index c19239e37cbffc3aa58f06ce788394672da866dd..80ceeadb81357072cfdd11f4486b9d47b5612d84 100644 (file)
@@ -2948,10 +2948,14 @@ cfg_map_findclause(const cfg_type_t *map, const char *name) {
        REQUIRE(name != NULL);
 
        found = cfg_map_firstclause(map, &clauses, &idx);
-       while (name != NULL && strcasecmp(name, found->name)) {
+       while (found != NULL && name != NULL && strcasecmp(name, found->name)) {
                found = cfg_map_nextclause(map, &clauses, &idx);
        }
 
+       if (found == NULL) {
+               return found;
+       }
+
        return ((cfg_clausedef_t *)clauses) + idx;
 }