X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/905beba565b5f023c9407be7413a625e6bd70cf1..ec8679e9b667dd6de9ef29e0d01085b219901e3b:/pageant.c diff --git a/pageant.c b/pageant.c index 09ef17e1..f8d7ad2d 100644 --- a/pageant.c +++ b/pageant.c @@ -545,6 +545,15 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { WNDCLASS wndclass; MSG msg; + /* + * First bomb out totally if we are already running. + */ + if (FindWindow("Pageant", "Pageant")) { + MessageBox(NULL, "Pageant is already running", "Pageant Error", + MB_ICONERROR | MB_OK); + return 0; + } + instance = inst; if (!prev) { @@ -608,16 +617,28 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { /* * Process the command line and add RSA keys as listed on it. - * FIXME: we don't support spaces in filenames here. We should. */ { - char *p = cmdline; + char *p; + int inquotes = 0; + p = cmdline; while (*p) { while (*p && isspace(*p)) p++; if (*p && !isspace(*p)) { - char *q = p; - while (*p && !isspace(*p)) p++; - if (*p) *p++ = '\0'; + char *q = p, *pp = p; + while (*p && (inquotes || !isspace(*p))) + { + if (*p == '"') { + inquotes = !inquotes; + p++; + continue; + } + *pp++ = *p++; + } + if (*pp) { + if (*p) p++; + *pp++ = '\0'; + } add_keyfile(q); } }