linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: David Howells <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] request-key: Fix mishandling of last line of config file
Date: Sun, 24 Aug 2025 02:59:33 +0300	[thread overview]
Message-ID: <aKpV5fk5X-plntzk@kernel.org> (raw)
In-Reply-To: <20250822142215.2475014-3-dhowells@redhat.com>

On Fri, Aug 22, 2025 at 03:22:09PM +0100, David Howells wrote:
> Fix mishandling of the config file by /sbin/request-key whereby the last
> line of a file, if it is lacking a newline, will trim off the last
> character and then try and use that.  Return an error instead if we find a
> line without a newline char at the end.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>  request-key.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/request-key.c b/request-key.c
> index bf47c0a..d1feec3 100644
> --- a/request-key.c
> +++ b/request-key.c
> @@ -367,6 +367,8 @@ static void scan_conf_file(struct parameters *params, int dirfd, const char *con
>  		/* ignore blank lines and comments */
>  		if (len == 1 || buf[0] == '#' || isspace(buf[0]))
>  			continue;
> +		if (len == 0 || buf[len - 1] != '\n')
> +			line_error("Line missing newline\n");
>  
>  		buf[--len] = 0;
>  		p = buf;
> 

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

Looks good to me. And the next question is not directly related to
this patch per se.

Just a hypothetical question. What if for spurious reasons the config
file would have carriage returns?

BR, Jarkko

  reply	other threads:[~2025-08-23 23:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 14:22 [PATCH 0/7] keyutils: Add some fixes and updates David Howells
2025-08-22 14:22 ` [PATCH 1/7] lib: Fix a couple of potential signed oveflows David Howells
2025-08-23 23:25   ` Jarkko Sakkinen
2025-08-22 14:22 ` [PATCH 2/7] request-key: Fix mishandling of last line of config file David Howells
2025-08-23 23:59   ` Jarkko Sakkinen [this message]
2025-08-22 14:22 ` [PATCH 3/7] test: Hide endianness David Howells
2025-08-22 14:22 ` [PATCH 4/7] tests: Add skips for testing of unsupported features David Howells
2025-08-22 14:22 ` [PATCH 5/7] request-key: Add help text David Howells
2025-08-24  0:03   ` Jarkko Sakkinen
2025-08-22 14:22 ` [PATCH 6/7] request-key: Add a simpler debug test David Howells
2025-08-24  0:04   ` Jarkko Sakkinen
2025-08-22 14:22 ` [PATCH 7/7] request-key: Support the promised multiwildcard matching David Howells
2025-08-24  0:05   ` Jarkko Sakkinen

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=aKpV5fk5X-plntzk@kernel.org \
    --to=jarkko@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).