]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
keymgr: avoid segfault when using import-pem on a malformed key
authorJan Doskočil <jan.doskocil@nic.cz>
Tue, 13 Jan 2026 09:51:06 +0000 (10:51 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Tue, 13 Jan 2026 12:10:25 +0000 (13:10 +0100)
Co-authored-by: Hanno Böck <hanno@hboeck.de>
src/utils/keymgr/functions.c

index bbb2f8faf1b641ec4cde54fc2920b071ff09b790..df00464aaeeb3bb602c307165de6502026222470 100644 (file)
@@ -501,9 +501,12 @@ fail:
 
 static void err_import_key(char *keyid, const char *file)
 {
+       assert(file != NULL);
+
        ERR2("failed to get key%s%s from %s%s",
-            *keyid == '\0' ? "" : " ", keyid,
-            *file == '\0' ? "the keystore" : "file ", file);
+            (keyid == NULL || *keyid == '\0') ? "" : " ",
+            (keyid == NULL) ? "" : keyid,
+            (*file == '\0') ? "the keystore" : "file ", file );
 }
 
 static int import_key(kdnssec_ctx_t *ctx, unsigned backend, const char *param,