chiark / gitweb /
key/key-io.c: Produce valid key lines for empty keys.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 13 May 2017 15:29:09 +0000 (16:29 +0100)
If a key contains only an empty tree of structures, then `key_write'
returns an empty string, which breaks the whitespace-separated field
structure of the output key line.  Notice this and insert an empty
structure by hand as an unpleasant bodge.

The resulting key is still highly anomalous.  In particular, it doesn't
match any filter, because structure nodes don't have flags.  I don't
know what to do about this.

key/key-io.c

index b2dc9189b4f5c4bcf5ed6efb6c46d4b8efcbb2c1..c79c8e063ae0b2b8d2bab463d299a8ed74dcb8ea 100644 (file)
@@ -352,7 +352,7 @@ int key_extract(key_file *f, key *k, FILE *fp, const key_filter *kf)
 
   key_fulltag(k, &d);
   DPUTC(&d, ' ');
-  key_write(k->k, &d, kf);
+  if (!key_write(k->k, &d, kf)) dstr_puts(&d, "struct:[]");
   DPUTC(&d, ' ');
   dstr_write(&d, fp);
   DRESET(&d);