From: Hans Jerry Illikainen <hji@dyntopia.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/1] gpg-interface: limit search for primary key fingerprint
Date: Thu, 21 Nov 2019 23:19:12 +0000 [thread overview]
Message-ID: <87d0dkbyxb.hji@dyntopia.com> (raw)
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!).
> 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.
>> + 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 :)
> 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.
next prev parent reply other threads:[~2019-11-21 23:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-16 18:06 [PATCH 0/1] Limit search for primary key fingerprint Hans Jerry Illikainen
2019-11-16 18:06 ` [PATCH 1/1] gpg-interface: limit " Hans Jerry Illikainen
2019-11-18 5:40 ` Junio C Hamano
2019-11-21 23:19 ` Hans Jerry Illikainen [this message]
2019-11-22 2:39 ` Junio C Hamano
2019-11-22 3:44 ` Junio C Hamano
2019-11-22 20:23 ` Hans Jerry Illikainen
2019-11-23 0:18 ` Junio C Hamano
2019-11-16 19:49 ` [PATCH 0/1] Limit " Jonathan Nieder
2019-11-16 21:58 ` [PATCH v2 " Hans Jerry Illikainen
2019-11-16 21:58 ` [PATCH v2 1/1] gpg-interface: limit " Hans Jerry Illikainen
2019-11-21 23:43 ` [PATCH v3 0/2] gpg-interface: fix " Hans Jerry Illikainen
2019-11-21 23:43 ` [PATCH v3 1/2] gpg-interface: refactor the free-and-xmemdupz pattern Hans Jerry Illikainen
2019-11-22 2:45 ` Junio C Hamano
2019-11-21 23:43 ` [PATCH v3 2/2] gpg-interface: limit search for primary key fingerprint Hans Jerry Illikainen
2019-11-22 3:34 ` Junio C Hamano
2019-11-22 20:23 ` [PATCH v4 0/2] Limit search for primary fingerprint Hans Jerry Illikainen
2019-11-22 20:23 ` [PATCH v4 1/2] gpg-interface: refactor the free-and-xmemdupz pattern Hans Jerry Illikainen
2019-11-22 20:23 ` [PATCH v4 2/2] gpg-interface: limit search for primary key fingerprint Hans Jerry Illikainen
2019-11-23 0:22 ` [PATCH v4 0/2] Limit search for primary fingerprint Junio C Hamano
2019-11-18 4:45 ` [PATCH 0/1] Limit search for primary key fingerprint Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d0dkbyxb.hji@dyntopia.com \
--to=hji@dyntopia.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).