From b1182cd3f0e7369aec459444949ee504929e89c4 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 21 Nov 2019 17:43:51 +0000 Subject: [PATCH] key/key-data.c (key_copydata): Fix catastrophic bug. Organization: Straylight/Edgeware From: Mark Wooding The fundamental problem is that the key-encoding test has the wrong sense. The result is that we end up (only) trying to iterate over non- structured keys, which results in an assertion failure. Also, switch things around so that we check the encoding type before checking the flags. --- key/key-data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/key/key-data.c b/key/key-data.c index 3a0b7351..cd5c8d78 100644 --- a/key/key-data.c +++ b/key/key-data.c @@ -428,8 +428,8 @@ static int structmatchp(key_data *k, const key_filter *kf) { key_subkeyiter i; - if (!KEY_MATCH(k, kf)) return (0); - else if ((k->e & KF_ENCMASK) == KENC_STRUCT) return (1); + if ((k->e & KF_ENCMASK) != KENC_STRUCT) + return (KEY_MATCH(k, kf)); else { for (key_mksubkeyiter(&i, k); key_nextsubkey(&i, 0, &k); ) if (!structmatchp(k, kf)) return (0); -- [mdw]