Commit d5e95342b5 for strongswan.org

commit d5e95342b5ce6df7da9f0605ebee36c6a5df3482
Author: Tobias Brunner <tobias@strongswan.org>
Date:   Mon Feb 23 11:20:19 2026 +0100

    swanctl: Check for conflicts with existing and shared options when registering commands

diff --git a/src/pki/command.c b/src/pki/command.c
index 18a3b7dedb..5c765ba92a 100644
--- a/src/pki/command.c
+++ b/src/pki/command.c
@@ -222,6 +222,25 @@ void command_register(command_t command)
 				"MAX_COMMANDS\n");
 		return;
 	}
+	for (i = 0; i < MAX_COMMANDS && cmds[i].cmd; i++)
+	{
+		if (cmds[i].op == command.op)
+		{
+			fprintf(stderr, "unable to register command --%s, short option "
+					"conflicts with --%s\n", command.cmd, cmds[i].cmd);
+			return;
+		}
+	}
+	for (i = 0; i < countof(shared_options); i++)
+	{
+		if (shared_options[i].op == command.op)
+		{
+			fprintf(stderr, "unable to register command --%s, short option "
+					"-%c conflicts with --%s\n", command.cmd, command.op,
+					shared_options[i].name);
+			return;
+		}
+	}

 	cmds[registered] = command;
 	/* append default options, but not to --help */