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, 22 Apr 2017 19:15:34 +0000 (20:15 +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 df7cd53ff1a02189fbf4c328713d60fae5cf8525..843f81d8a82c811ba09fa97eacab53daeb6757bc 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);