From: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
To: mhiramat@kernel.org
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] tools/bootconfig: Reject extra positional operands
Date: Thu, 26 Nov 2026 00:40:04 +0100 [thread overview]
Message-ID: <6e1358cefd6ed85c1c264cfbe195b913a8a0aca1.1795650002.git.edumucelli@gmail.com> (raw)
The bootconfig CLI accepts one input path but only checks whether a path
is missing. Commands with several operands act on the first one and can
report successful completion. For example, bootconfig -d first.img
second.img removes bootconfig from only the first image and exits zero.
Reject surplus operands before calling the command handler. Add tests
for list, apply and delete with an extra path.
Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
Hi Masami,
I ran into this while checking how the tool handles more than one input
path. An extra argument was easy to miss because the command still
succeeded. I added cases for list, apply and delete and ran the full
bootconfig CLI suite on my Ubuntu machine.
Thanks,
Eduardo
tools/bootconfig/main.c | 5 +++++
tools/bootconfig/test-bootconfig.sh | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index c85e58fcb6b0b7..3e56a618fe3a58 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -592,6 +592,11 @@ int main(int argc, char **argv)
return usage();
}
+ if (argc - optind > 1) {
+ pr_err("Error: Specify only one input path.\n");
+ return usage();
+ }
+
path = argv[optind];
if (apply)
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index a93a40d11d278f..ac0ffeffe1f7ce 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -71,6 +71,11 @@ xpass $BOOTCONF -a $TEMPCONF $INITRD
echo "File size check"
xpass test $new_size -eq $(wc -c < $INITRD)
+echo "Reject an extra positional path"
+xfail $BOOTCONF -l $INITRD $OUTFILE
+xfail $BOOTCONF -a $TEMPCONF $INITRD $OUTFILE
+xfail $BOOTCONF -d $INITRD $OUTFILE
+
echo "Delete command check"
xpass $BOOTCONF -d $INITRD
base-commit: 56bb11fe6aacc7666938e8e6765b44aa0cf1fcdd
--
2.53.0
reply other threads:[~2026-11-25 23:40 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=6e1358cefd6ed85c1c264cfbe195b913a8a0aca1.1795650002.git.edumucelli@gmail.com \
--to=edumucelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@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®