]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Require valid key for dst_key functions
authorMatthijs Mekking <matthijs@isc.org>
Tue, 17 May 2022 10:02:43 +0000 (12:02 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 23 May 2022 10:00:53 +0000 (12:00 +0200)
Make sure that the key structure is valid when calling the following
functions:
- dst_key_setexternal
- dst_key_isexternal
- dst_key_setmodified
- dst_key_ismodified

(cherry picked from commit 888ec4e0d407a9333017d6997a2be81a69658e1f)

lib/dns/dst_api.c

index 237ddc05153495a1cb19f1165dafa26bf0ebcc43..39fcbf1fa67066935fa4015cc51d19bc1f161658 100644 (file)
@@ -461,16 +461,22 @@ dst_key_tofile(const dst_key_t *key, int type, const char *directory) {
 
 void
 dst_key_setexternal(dst_key_t *key, bool value) {
+       REQUIRE(VALID_KEY(key));
+
        key->external = value;
 }
 
 bool
 dst_key_isexternal(dst_key_t *key) {
+       REQUIRE(VALID_KEY(key));
+
        return (key->external);
 }
 
 void
 dst_key_setmodified(dst_key_t *key, bool value) {
+       REQUIRE(VALID_KEY(key));
+
        isc_mutex_lock(&key->mdlock);
        key->modified = value;
        isc_mutex_unlock(&key->mdlock);
@@ -480,6 +486,8 @@ bool
 dst_key_ismodified(const dst_key_t *key) {
        bool modified;
 
+       REQUIRE(VALID_KEY(key));
+
        isc_mutex_lock(&(((dst_key_t *)key)->mdlock));
        modified = key->modified;
        isc_mutex_unlock(&(((dst_key_t *)key)->mdlock));