From: David Howells <dhowells@redhat.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: David Howells <dhowells@redhat.com>,
keyrings@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] request-key: Fix mishandling of last line of config file
Date: Fri, 22 Aug 2025 15:22:09 +0100 [thread overview]
Message-ID: <20250822142215.2475014-3-dhowells@redhat.com> (raw)
In-Reply-To: <20250822142215.2475014-1-dhowells@redhat.com>
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;
next prev parent reply other threads:[~2025-08-22 14:22 UTC|newest]
Thread overview: 14+ 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 ` David Howells [this message]
2025-08-23 23:59 ` [PATCH 2/7] request-key: Fix mishandling of last line of config file Jarkko Sakkinen
2025-11-19 15:53 ` David Howells
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=20250822142215.2475014-3-dhowells@redhat.com \
--to=dhowells@redhat.com \
--cc=jarkko@kernel.org \
--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
all inboxes | Powered by JetHome®