mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tools/bootconfig: Reject extra positional operands
@ 2026-11-25 23:40 Eduardo Mucelli Rezende Oliveira
  0 siblings, 0 replies; only message in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-11-25 23:40 UTC (permalink / raw)
  To: mhiramat; +Cc: linux-trace-kernel, linux-kernel

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-25 23:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 23:40 [PATCH] tools/bootconfig: Reject extra positional operands Eduardo Mucelli Rezende Oliveira

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®