From: Scott Mayhew <smayhew@redhat.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [nfs-utils PATCH] fsidd: replace assertions with explicit malformed-input handling
Date: Thu, 3 Sep 2026 13:48:47 -0400 [thread overview]
Message-ID: <20260903174847.1213636-1-smayhew@redhat.com> (raw)
fsidd relies on assert() to ensure that an argument is present after the
command prefix while parsing commands received over the local socket.
Malformed input can cause fsidd to abort. Replace the assertions with
explicit malformed-input handling and return an error to the client.
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
support/reexport/fsidd.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/support/reexport/fsidd.c b/support/reexport/fsidd.c
index 51750ea3..f5c397aa 100644
--- a/support/reexport/fsidd.c
+++ b/support/reexport/fsidd.c
@@ -48,7 +48,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
char *answer = NULL;
bool found;
- assert(req_path < buf + n );
+ if (req_path >= buf + n) {
+ char answer[] = "- Command failed: Bad input";
+ (void)send(cl, answer, strlen(answer), 0);
+ return;
+ }
printf("client asks for %s\n", req_path);
@@ -70,8 +74,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
char *answer = NULL;
bool found;
- assert(req_path < buf + n );
-
+ if (req_path >= buf + n) {
+ char answer[] = "- Command failed: Bad input";
+ (void)send(cl, answer, strlen(answer), 0);
+ return;
+ }
if (dbbackend->fsidnum_by_path(req_path, &fsidnum, true, &found)) {
if (found) {
@@ -94,7 +101,11 @@ static void client_cb(evutil_socket_t cl, short ev, void *d)
uint32_t fsidnum;
bool found;
- assert(req_fsidnum < buf + n );
+ if (req_fsidnum >= buf + n) {
+ char answer[] = "- Command failed: Bad input";
+ (void)send(cl, answer, strlen(answer), 0);
+ return;
+ }
errno = 0;
fsidnum = strtoul(req_fsidnum, &endp, 10);
--
2.55.0
reply other threads:[~2026-09-03 17:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260903174847.1213636-1-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/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