chiark / gitweb /
key/key-data.c (key_copydata): Fix catastrophic bug.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 21 Nov 2019 17:43:51 +0000 (17:43 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 16 Dec 2019 16:25:17 +0000 (16:25 +0000)
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

index 3a0b7351a4beaf971a7b1e6bc2b6e9be4e70f561..cd5c8d781f1151b498a18cb67026962e48ed20d1 100644 (file)
@@ -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);