git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] gpg-interface: limit search for primary key fingerprint

From
Hans Jerry Illikainen <hji@dyntopia.com>
Date
Nov 21, 2019, 23:19 UTC
Message-ID
<87d0dkbyxb.hji@dyntopia.com>
In-Reply-To
<xmqqtv712145.fsf@gitster-ct.c.googlers.com>
On Mon, Nov 18 2019, Junio C Hamano wrote:
> I wonder if it is simpler to define it next to 'next'.  Yes, this
> new variable is used only within this block, but it also gets used
> only in conjunction with that other variable.
Done in v3 (sorry for the messed up versioning going from v0 to v2!).
Show 8 quoted lines
> A bigger question is, when this happens, what value do we want to
> leave in sigc->primary_key_fingerprint?  As we can see from the
> original code that makes sure the old value in the field will not
> leak by first free()ing, it seems that it is possible in this code
> that the field may not be NULL, but we just saw that on _our_
> signature verification system, the primary key is not available.
> Shouldn't we be nulling it out, after free()ing possibly leftover
> value in the field?

I investigated the code paths to `primary_key_fingerprint` and deduced that it's only ever touched when GPG_STATUS_FINGERPRINT is encountered and a primary fingerprint is extracted. However, v3 will NULL it even when no primary fingerprint is found.

Show 6 quoted lines
>> +							xmemdupz(line,
>> +								 next - line);
>> +					}
>
> Avoid such an unnatural line-wrapping that makes the result harder
> to read.

Sorry about that! I figured that some projects prefer to always trust in the code formatter; so I just left it be. Now I know that human decisions are allowed :)

Show 14 quoted lines
> A short helper
>
> 	static void replace_cstring(const char **field,
> 				    const char *line, const char *next)
> 	{
> 		free(*field);
> 		if (line && next)
> 			*field = xmemdupz(line, next - line);
> 		else
> 			*field = NULL;
> 	}
>
> may have quite a lot of uses in this function, not only for this
> field.

Implemented. I wasn't sure whether to do it in a separate commit or not, but #git-devel suggested that I do; so that's what I did.

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 21 in “Limit search for primary key fingerprint”
  1. 0/1 Limit search for primary key fingerprintHans Jerry Illikainen, Nov 16, 2019
  2. 1/1 gpg-interface: limit search for primary key fingerprintHans Jerry Illikainen, Nov 16, 2019
  3. Junio C HamanoNov 18, 2019
  4. Hans Jerry IllikainenNov 21, 2019
  5. Junio C HamanoNov 22, 2019
  6. Junio C HamanoNov 22, 2019
  7. Hans Jerry IllikainenNov 22, 2019
  8. Junio C HamanoNov 23, 2019
  9. Jonathan NiederNov 16, 2019
  10. 0/1 Limit search for primary key fingerprintHans Jerry Illikainen, Nov 16, 2019
  11. 1/1 gpg-interface: limit search for primary key fingerprintHans Jerry Illikainen, Nov 16, 2019
  12. 0/2 gpg-interface: fix search for primary key fingerprintHans Jerry Illikainen, Nov 21, 2019
  13. 1/2 gpg-interface: refactor the free-and-xmemdupz patternHans Jerry Illikainen, Nov 21, 2019
  14. Junio C HamanoNov 22, 2019
  15. 2/2 gpg-interface: limit search for primary key fingerprintHans Jerry Illikainen, Nov 21, 2019
  16. Junio C HamanoNov 22, 2019
  17. 0/2 Limit search for primary fingerprintHans Jerry Illikainen, Nov 22, 2019
  18. 1/2 gpg-interface: refactor the free-and-xmemdupz patternHans Jerry Illikainen, Nov 22, 2019
  19. 2/2 gpg-interface: limit search for primary key fingerprintHans Jerry Illikainen, Nov 22, 2019
  20. Junio C HamanoNov 23, 2019
  21. Junio C HamanoNov 18, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.