On Wed, Nov 03, 2021 at 06:48:51PM +0100, Theo Buehler wrote:
> On Wed, Nov 03, 2021 at 06:34:05PM +0100, Claudio Jeker wrote:
> > Fix CRLF handling by properly setting nl to the right NUL byte.
> > In the CRLF case both \r\n are replaced by \0 and so the code
> > needs to adjust the nl pointer else valid_url() and the check for .cer
> > endings fail.
>
> It feels odd to interrupt CRLF handling by advancing the buffer to the
> next line.
>
> How about this?
Much better. OK claudio@
> Index: tal.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/tal.c,v
> retrieving revision 1.32
> diff -u -p -r1.32 tal.c
> --- tal.c 26 Oct 2021 16:12:54 -0000 1.32
> +++ tal.c 3 Nov 2021 17:47:40 -0000
> @@ -58,14 +58,16 @@ tal_parse_buffer(const char *fn, char *b
> while ((nl = memchr(buf, '\n', len)) != NULL) {
> line = buf;
>
> - /* replace LF and optional CR with NUL */
> - *nl = '\0';
> - if (nl > line && nl[-1] == '\r')
> - nl[-1] = '\0';
> -
> /* advance buffer to next line */
> len -= nl + 1 - buf;
> buf = nl + 1;
> +
> + /* replace LF and optional CR with NUL, point nl at first NUL */
> + *nl = '\0';
> + if (nl > line && nl[-1] == '\r') {
> + nl[-1] = '\0';
> + nl--;
> + }
>
> if (optcomment) {
> /* if this is a comment, just eat the line */
>
--
:wq Claudio