Re: [PATCH] gpg-interface: trim CR from ssh-keygen -Y find-principals
- From
Fabian Stelzer <fs@gigacodes.de>
- Date
- Dec 9, 2021, 16:33 UTC
- Message-ID
- <20211209163346.w5ofhoapmjnpgc6y@fs>
- In-Reply-To
- <CABPYr=y+sDDko9zPxQTOM6Tz4E7CafH7hJc6oB1zv7XYA9KH1A@mail.gmail.com>
On 06.12.2021 10:06, Pedro Martelletto wrote:
Show 14 quoted lines
>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);
- Fabian
Show 6 quoted lines
>trust_size = strcspn(line, "\n"); /* truncate at LF */ >if (trust_size && trust_size != strlen(line) && line[trust_size - 1] == >'\r') > trust_size--; /* the LF was part of CRLF at the end */ > >-p.