From: Fabian Stelzer <fs@gigacodes.de>
To: Pedro Martelletto <pedro@yubico.com>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Damien Miller <djm@mindrot.org>
Subject: Re: [PATCH] gpg-interface: trim CR from ssh-keygen -Y find-principals
Date: Thu, 9 Dec 2021 18:20:32 +0100 [thread overview]
Message-ID: <20211209172032.2iyda3rv4zsjry3s@fs> (raw)
In-Reply-To: <CABPYr=xfotWvTQK9k1eKHa0kP4SsB=TKKuM0d8cpMb5BtuUZLA@mail.gmail.com>
On 09.12.2021 17:58, Pedro Martelletto wrote:
>On Thu, Dec 9, 2021 at 5:33 PM Fabian Stelzer <fs@gigacodes.de> wrote:
>
>> On 06.12.2021 10:06, Pedro Martelletto wrote:
>> >On Sun, Dec 5, 2021 at 6:50 AM Junio C Hamano <gitster@pobox.com> wrote:
>> >
>> >> So instead of the posted patch, we should do something along this
>> >> line instead?
>> >>
>> >> trust_size = strcspn(line, "\n"); /* truncate at LF */
>> >> if (trust_size && line[trust_size - 1] == '\r')
>> >> trust_size--; /* the LF was part of CRLF at the end */
>> >>
>> >>
>> >>
>> >I agree that's a more consistent fix. A minor nit: if the intention is to
>> >only trim CR as part of a CRLF sequence, we need to ensure a LF is found:
>> >
>>
>> This shouldn't be necessary as we split/loop by LF just above.
>>
>> for (line = ssh_principals_out.buf; *line;
>> line = strchrnul(line + 1, '\n')) {
>> while (*line == '\n')
>> line++;
>> if (!*line)
>> break;
>>
>> trust_size = strcspn(line, "\n");
>> principal = xmemdupz(line, trust_size);
>>
>
>The loop ensures that 'line' points to the first character of
>ssh_principals_out.buf or to a non-NUL character after a '\n'. It does not
>ensure that that 'line' contains a '\n', e.g:
>"principalA\nprincipalB\nprincipalC\r" or just "principalA\r".
>
Oops, yep. You are of course right.
I still dislike how we have to consider this in various places and i guess
there might be more bugs hidden on the windows platform with things like
this. I kinda wish we could strip \r\n -> \n within pipe_command and then
have the rest of the code not have to deal with it :/
Especially since writing a test for this would involve mirroring at leas
parts oft the ssh-keygen api.
But that would be a much bigger/riskier change so for this i think your
latest version is fine.
-
Fabian
next prev parent reply other threads:[~2021-12-09 17:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-03 13:31 [PATCH] gpg-interface: trim CR from ssh-keygen -Y find-principals Johannes Schindelin via GitGitGadget
2021-12-03 14:18 ` Fabian Stelzer
2021-12-03 15:58 ` Jeff King
2021-12-04 13:11 ` Fabian Stelzer
2021-12-05 5:50 ` Junio C Hamano
[not found] ` <CABPYr=y+sDDko9zPxQTOM6Tz4E7CafH7hJc6oB1zv7XYA9KH1A@mail.gmail.com>
2021-12-09 16:33 ` Fabian Stelzer
[not found] ` <CABPYr=xfotWvTQK9k1eKHa0kP4SsB=TKKuM0d8cpMb5BtuUZLA@mail.gmail.com>
2021-12-09 17:20 ` Fabian Stelzer [this message]
2021-12-30 10:25 ` Fabian Stelzer
2021-12-05 23:06 ` Damien Miller
2021-12-06 8:39 ` Fabian Stelzer
2022-01-03 9:53 ` [PATCH v2] gpg-interface: trim CR from ssh-keygen Fabian Stelzer
2022-01-03 17:17 ` Eric Sunshine
2022-01-03 23:34 ` Junio C Hamano
2022-01-04 0:41 ` Eric Sunshine
2022-01-04 1:19 ` Junio C Hamano
2022-01-04 3:06 ` Eric Sunshine
2022-01-04 12:55 ` Fabian Stelzer
2022-01-04 19:33 ` Junio C Hamano
2022-01-05 7:09 ` Eric Sunshine
2022-01-05 10:36 ` Fabian Stelzer
2022-01-05 20:40 ` Junio C Hamano
2022-01-06 10:26 ` Fabian Stelzer
2022-01-06 17:50 ` Junio C Hamano
2022-01-09 20:49 ` Eric Sunshine
2022-01-10 12:28 ` Fabian Stelzer
2022-01-07 9:07 ` [PATCH v3] " Fabian Stelzer
2022-01-09 21:37 ` Eric Sunshine
2022-01-10 12:59 ` Fabian Stelzer
2022-01-10 17:51 ` Junio C Hamano
2022-01-10 17:03 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211209172032.2iyda3rv4zsjry3s@fs \
--to=fs@gigacodes.de \
--cc=djm@mindrot.org \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=pedro@yubico.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).