[PATCH] fix keystrlen when no keyid-format option has been given

Werner Koch wk at gnupg.org
Thu Dec 10 17:29:58 CET 2015

On Wed,  9 Dec 2015 19:01, dkg at fifthhorseman.net said:
> * g10/keyid.c (keystrlen): if opt.keyid_format has not been set,
>   default to 0xLONG, as is done in format_keyid.

> gpgv: Ohhhh jeeee: ... this is a bug (keyid.c:342:keystrlen)

Neal, why did you introduced the KF_DEFAULT at all?  I can't immediately
the the reason.

While looking at the code I also wonder why we do this:

      if (keyid[0])
	snprintf (buffer, len, "%08lX%08lX",
                  (ulong)keyid[0], (ulong)keyid[1]);
	snprintf (buffer, len, "%08lX", (ulong)keyid[1]);

This break the column alignment for keyis 0x00000000xxxxxxxxx . Granted,
this is a rare case but why should be do that at all, the commit message
from 2004 says:

    * keyid.c (keystr): If printing a keyid that lacks the high 4 bytes, print
    the low 4 alone. (keystr_from_desc): Handle short keyids and warn on v3

However, last year I fixed the indentation in some messages to match the
current keyid format - this requires that keyid has a constant length.



Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

More information about the Gnupg-devel mailing list