From af3520d245c4c027eacb8e4efa2542f7f1e3a411 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 4 May 2022 19:57:47 +0100 Subject: [PATCH] Windows Pageant: fix off-by-one in -c option. Apparently I never re-tested that option when I revamped Pageant's command-line option parsing in commit dc183e1649b429a, because it's now off by one in figuring out which argument to treat as the start of the command to be run. (The new code in that commit is the same shape as the old code but with variables renamed, and that was the mistake, because in the old code, the argument index i pointed to the -c option, whereas in the new code, match_opt has already advanced amo.index to the next word. So the two index variables _shouldn't_ be treated the same.) --- windows/pageant.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/pageant.c b/windows/pageant.c index 5ba16801..dd8db40b 100644 --- a/windows/pageant.c +++ b/windows/pageant.c @@ -1504,8 +1504,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) * If we see `-c', then the rest of the command line * should be treated as a command to be spawned. */ - if (amo.index < amo.argc-1) - command = argstart[amo.index + 1]; + if (amo.index < amo.argc) + command = argstart[amo.index]; else command = ""; break;