VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Format
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-04-26 15:57:43 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-04-27 23:59:49 +0200
commitdc3bc64b8685aeec3ab461e632a1604833ed6fd6 (patch)
tree59aa850fb96aabe3212e946b5dfdce5d074a81e2 /src/Format
parent9ccb8a97afe66516b02da88b0997cc0d944a1010 (diff)
downloadVeraCrypt-dc3bc64b8685aeec3ab461e632a1604833ed6fd6.tar.gz
VeraCrypt-dc3bc64b8685aeec3ab461e632a1604833ed6fd6.zip
Windows: Better command line handling to make it more strict and robust. This avoids issues when using wrong syntax.
Diffstat (limited to 'src/Format')
-rw-r--r--src/Format/Tcformat.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index b32ce0ce..2bff1963 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -7831,7 +7831,6 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
OptionHistory,
OptionNoIsoCheck,
- OptionQuit,
OptionTokenLib,
CommandResumeSysEncLogOn,
CommandResumeSysEnc,
@@ -7848,7 +7847,6 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
{ OptionHistory, "/history", "/h", FALSE },
{ OptionNoIsoCheck, "/noisocheck", "/n", FALSE },
- { OptionQuit, "/quit", "/q", FALSE },
{ OptionTokenLib, "/tokenlib", NULL, FALSE },
{ CommandResumeSysEncLogOn, "/acsysenc", "/a", TRUE },
@@ -7864,7 +7862,6 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
argumentspec as;
- int nArgPos;
int x;
if (lpszCommandLineArgs[i] == NULL)
@@ -7873,7 +7870,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
as.args = args;
as.arg_cnt = sizeof(args)/ sizeof(args[0]);
- x = GetArgumentID (&as, lpszCommandLineArgs[i], &nArgPos);
+ x = GetArgumentID (&as, lpszCommandLineArgs[i]);
switch (x)
{
@@ -8004,37 +8001,33 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionHistory:
{
- char szTmp[8];
- GetArgumentValue (lpszCommandLineArgs, nArgPos, &i, nNoCommandLineArgs,
- szTmp, sizeof (szTmp));
- if (!_stricmp(szTmp,"y") || !_stricmp(szTmp,"yes"))
- {
- bHistory = TRUE;
- bHistoryCmdLine = TRUE;
- }
+ char szTmp[8] = {0};
+ bHistory = bHistoryCmdLine = TRUE;
- if (!_stricmp(szTmp,"n") || !_stricmp(szTmp,"no"))
+ if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
+ szTmp, sizeof (szTmp)))
{
- bHistory = FALSE;
- bHistoryCmdLine = TRUE;
+ if (!_stricmp(szTmp,"y") || !_stricmp(szTmp,"yes"))
+ {
+ bHistory = TRUE;
+ }
+
+ else if (!_stricmp(szTmp,"n") || !_stricmp(szTmp,"no"))
+ {
+ bHistory = FALSE;
+ }
+ else
+ AbortProcess ("COMMAND_LINE_ERROR");
}
}
break;
case OptionTokenLib:
- if (GetArgumentValue (lpszCommandLineArgs, nArgPos, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
+ if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
InitSecurityTokenLibrary(hwndDlg);
else
- Error ("COMMAND_LINE_ERROR", hwndDlg);
-
- break;
+ AbortProcess ("COMMAND_LINE_ERROR");
- case OptionQuit:
- {
- // Used to indicate non-install elevation
- char szTmp[32];
- GetArgumentValue (lpszCommandLineArgs, nArgPos, &i, nNoCommandLineArgs, szTmp, sizeof (szTmp));
- }
break;
default: