From 32dfb7e1817f5e1772cde1aefc9c00b0162f9464 Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 1 Oct 2004 21:15:24 +0000 Subject: [PATCH] =?UTF-8?q?both=20=5F=3D=3F=20and=20/D=3D=20now=20require?= =?UTF-8?q?=20a=20space=20before=20them=20so=20they=20can=20safely=20remov?= =?UTF-8?q?e=20the=20space=20from=20$CMDLINE?= git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3692 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index eb9f2098..cca9a559 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -141,13 +141,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, cl_flags |= FH_FLAGS_SILENT; #endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_CRC_SUPPORT - if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) + if (*(LPDWORD)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) cl_flags |= FH_FLAGS_NO_CRC; #endif//NSIS_CONFIG_CRC_SUPPORT - if (*(WORD*)cmdline == CHAR2_TO_WORD('D','=')) + if (*(LPDWORD)(cmdline-2) == CHAR4_TO_DWORD(' ', '/', 'D','=')) { - cmdline[-1]=0; // keep this from being passed to uninstaller if necessary + cmdline[-2]=0; // keep this from being passed to uninstaller if necessary mystrcpy(state_install_directory,cmdline+2); break; // /D= must always be last } @@ -168,14 +168,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, { char *p = findchar(realcmds, 0); - while (p >= realcmds && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--; + // state_command_line has state_install_directory right after it in memory, so reading + // a bit over state_command_line won't do any harm + while (p >= realcmds && *(LPDWORD)p != CHAR4_TO_DWORD(' ', '_', '?', '=')) p--; m_Err = _LANG_UNINSTINITERROR; if (p >= realcmds) { - *p=0; // terminate before the "_?=" - p+=3; // skip over _?= + *p=0; // terminate before "_?=" + p+=4; // skip over " _?=" if (is_valid_instpath(p)) { mystrcpy(state_install_directory, p);