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.
- 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);
else {
for (key_mksubkeyiter(&i, k); key_nextsubkey(&i, 0, &k); )
if (!structmatchp(k, kf)) return (0);