diff options
Diffstat (limited to 'src/Mount/Mount.c')
-rw-r--r-- | src/Mount/Mount.c | 80 |
1 files changed, 50 insertions, 30 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 2bbb8af8..86337d6b 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -1551,9 +1551,17 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive) GetSizeString (GetSysEncDeviceSize(TRUE), szTmpW, sizeof(szTmpW));
ListSubItemSet (hTree, listItem.iItem, 2, szTmpW);
- EAGetName (szTmp, propSysEnc.ea, 1);
+ if (propSysEnc.ea >= EAGetFirst() && propSysEnc.ea <= EAGetCount())
+ {
+ EAGetName (szTmp, propSysEnc.ea, 1);
+ }
+ else
+ {
+ szTmp[0] = L'?';
+ szTmp[1] = 0;
+ }
listItem.iSubItem = 3;
ListView_SetItem (hTree, &listItem);
ListSubItemSet (hTree, listItem.iItem, 4, GetString (IsHiddenOSRunning() ? "HIDDEN" : "SYSTEM_VOLUME_TYPE_ADJECTIVE"));
@@ -3001,9 +3009,9 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa {
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
- DragQueryFile (hdrop, i++, kf->FileName, sizeof (kf->FileName));
+ DragQueryFile (hdrop, i++, kf->FileName, ARRAYSIZE (kf->FileName));
FirstKeyFile = KeyFileAdd (FirstKeyFile, kf);
KeyFilesEnable = TRUE;
}
}
@@ -3743,9 +3751,9 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP // Encryption algorithm
ListItemAdd (list, i, GetString ("ENCRYPTION_ALGORITHM"));
- if (prop.ea == 0 || prop.ea > EAGetCount ())
+ if (prop.ea < EAGetFirst() || prop.ea > EAGetCount ())
{
ListSubItemSet (list, i, 1, L"?");
return 1;
}
@@ -5848,15 +5856,15 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate) selDrive = (wchar_t) HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST)));
LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
NormalCursor ();
- if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
+ if (selDrive != ((wchar_t) 0xFFFF) && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
{
nSelectedDriveIndex = -1;
return FALSE;
}
- if (selDrive != -1)
+ if (selDrive != ((wchar_t) 0xFFFF))
SelectItem (GetDlgItem (MainDlg, IDC_DRIVELIST),selDrive);
}
try
@@ -5899,14 +5907,14 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate) LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), driveLetterToRefresh);
RecentBootEncStatus = newBootEncStatus;
- if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
+ if (selDrive != ((wchar_t) 0xFFFF) && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
{
nSelectedDriveIndex = -1;
}
- if (selDrive != -1)
+ if (selDrive != ((wchar_t) 0xFFFF))
{
SelectItem (GetDlgItem (MainDlg, IDC_DRIVELIST),selDrive);
}
}
@@ -6068,11 +6076,11 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam) if (ListView_GetItemPosition (hList, nSelectedDriveIndex, &pt))
{
pt.x += 2 + ::GetSystemMetrics(SM_CXICON);
pt.y += 2;
- ClientToScreen (hList, &pt);
- mPos = MAKELONG (pt.x, pt.y);
}
+ ClientToScreen (hList, &pt);
+ mPos = MAKELONG (pt.x, pt.y);
}
menuItem = TrackPopupMenu (popup,
TPM_RETURNCMD | TPM_LEFTBUTTON,
@@ -6276,10 +6284,10 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa defaultMountOptions = mountOptions;
if (FirstCmdKeyFile)
{
KeyFilesEnable = defaultKeyFilesParam.EnableKeyFiles = TRUE;
- FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
- defaultKeyFilesParam.FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
+ KeyFileCloneAll (FirstCmdKeyFile, &FirstKeyFile);
+ KeyFileCloneAll (FirstCmdKeyFile, &defaultKeyFilesParam.FirstKeyFile);
}
if (!MountAllDevices (hwndDlg, !Silent && !CmdVolumePasswordValid && IsPasswordCacheEmpty()))
exitCode = 1;
@@ -6290,10 +6298,10 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa defaultMountOptions = mountOptions;
if (FirstCmdKeyFile)
{
KeyFilesEnable = defaultKeyFilesParam.EnableKeyFiles = TRUE;
- FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
- defaultKeyFilesParam.FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
+ KeyFileCloneAll (FirstCmdKeyFile, &FirstKeyFile);
+ KeyFileCloneAll (FirstCmdKeyFile, &defaultKeyFilesParam.FirstKeyFile);
}
if (!MountFavoriteVolumes (hwndDlg, FALSE, LogOn))
exitCode = 1;
@@ -6341,8 +6349,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa }
if (FirstCmdKeyFile)
{
+ KeyFileRemoveAll (&FirstKeyFile);
FirstKeyFile = FirstCmdKeyFile;
KeyFilesEnable = TRUE;
}
@@ -7413,9 +7422,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa Warning ("NO_VOLUME_SELECTED", hwndDlg);
}
else
{
- GetVolumePath (hwndDlg, volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, ARRAYSIZE (volPath));
WaitCursor ();
int iStatus = 0;
@@ -8017,9 +8026,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_DROPFILES:
{
HDROP hdrop = (HDROP) wParam;
- DragQueryFile (hdrop, 0, szFileName, sizeof szFileName);
+ DragQueryFile (hdrop, 0, szFileName, ARRAYSIZE (szFileName));
DragFinish (hdrop);
AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
EnableDisableButtons (hwndDlg);
@@ -8172,9 +8181,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) wchar_t szTmp[32] = {0};
bAuto = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
+ &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
{
if (!_wcsicmp (szTmp, L"devices"))
bAutoMountDevices = TRUE;
else if (!_wcsicmp (szTmp, L"favorites"))
@@ -8197,9 +8206,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) bCmdTryEmptyPasswordWhenKeyfileUsed = TRUE;
bCmdTryEmptyPasswordWhenKeyfileUsedValid = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szTmp, sizeof (szTmp)))
+ szTmp, ARRAYSIZE (szTmp)))
{
if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
bCmdTryEmptyPasswordWhenKeyfileUsed = FALSE;
else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
@@ -8216,9 +8225,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) bCacheInDriver = TRUE;
bIncludePimInCache = FALSE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szTmp, sizeof (szTmp)))
+ szTmp, ARRAYSIZE (szTmp)))
{
if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
bCacheInDriver = FALSE;
else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
@@ -8241,9 +8250,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) case CommandDismount:
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szDriveLetter, sizeof (szDriveLetter)))
+ szDriveLetter, ARRAYSIZE (szDriveLetter)))
{
if ( (wcslen(szDriveLetter) == 1)
|| (wcslen(szDriveLetter) == 2 && szDriveLetter[1] == L':')
)
@@ -8271,16 +8280,16 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) break;
case OptionKeyfile:
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i,
- nNoCommandLineArgs, tmpPath, sizeof (tmpPath)))
+ nNoCommandLineArgs, tmpPath, ARRAYSIZE (tmpPath)))
{
KeyFile *kf;
RelativePath2Absolute (tmpPath);
kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
- StringCbCopyW (kf->FileName, sizeof(kf->FileName), tmpPath);
+ StringCchCopyW (kf->FileName, ARRAYSIZE(kf->FileName), tmpPath);
FirstCmdKeyFile = KeyFileAdd (FirstCmdKeyFile, kf);
}
}
else
@@ -8289,9 +8298,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) break;
case OptionLetter:
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szDriveLetter, sizeof (szDriveLetter)))
+ szDriveLetter, ARRAYSIZE (szDriveLetter)))
{
if ( (wcslen(szDriveLetter) == 1)
|| (wcslen(szDriveLetter) == 2 && szDriveLetter[1] == L':')
)
@@ -8314,9 +8323,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) wchar_t szTmp[8] = {0};
bHistory = bHistoryCmdLine = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szTmp, sizeof (szTmp)))
+ szTmp, ARRAYSIZE (szTmp)))
{
if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
bHistory = FALSE;
else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
@@ -8330,9 +8339,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) case OptionMountOption:
{
wchar_t szTmp[64] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
+ &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
{
if (!_wcsicmp (szTmp, L"ro") || !_wcsicmp (szTmp, L"readonly"))
mountOptions.ReadOnly = TRUE;
@@ -8369,9 +8378,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) case OptionPassword:
{
wchar_t szTmp[MAX_PASSWORD + 1];
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szTmp, sizeof (szTmp)))
+ szTmp, ARRAYSIZE (szTmp)))
{
int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (char*) CmdVolumePassword.Text, MAX_PASSWORD + 1, NULL, NULL);
burn (szTmp, sizeof (szTmp));
if (iLen > 0)
@@ -8388,9 +8397,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) break;
case OptionVolume:
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i,
- nNoCommandLineArgs, szFileName, sizeof (szFileName)))
+ nNoCommandLineArgs, szFileName, ARRAYSIZE (szFileName)))
{
RelativePath2Absolute (szFileName);
AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
CmdLineVolumeSpecified = TRUE;
@@ -8403,9 +8412,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) {
wchar_t szTmp[32] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
+ &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
{
if (!_wcsicmp (szTmp, L"UAC")) // Used to indicate non-install elevation
break;
@@ -8432,9 +8441,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) Silent = TRUE;
break;
case OptionTokenLib:
- if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
+ if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, ARRAYSIZE (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
InitSecurityTokenLibrary(hwndDlg);
else
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8453,9 +8462,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) case OptionPkcs5:
{
wchar_t szTmp[32] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
+ &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
{
if (_wcsicmp(szTmp, L"sha512") == 0 || _wcsicmp(szTmp, L"sha-512") == 0)
CmdVolumePkcs5 = SHA512;
else if (_wcsicmp(szTmp, L"whirlpool") == 0)
@@ -8479,9 +8488,9 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) case OptionPim:
{
wchar_t szTmp[32] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
+ &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
{
wchar_t* endPtr = NULL;
CmdVolumePim = (int) wcstol(szTmp, &endPtr, 0);
if (CmdVolumePim < 0 || endPtr == szTmp || *endPtr != L'\0')
@@ -8869,8 +8878,19 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite, {
BOOL status = TRUE;
int drive;
drive = towupper (favorite.MountPoint[0]) - L'A';
+
+ if ((drive < MIN_MOUNTED_VOLUME_DRIVE_NUMBER) || (drive > MAX_MOUNTED_VOLUME_DRIVE_NUMBER))
+ {
+ if (!systemFavorites)
+ Error ("DRIVE_LETTER_UNAVAILABLE", MainDlg);
+ else if (ServiceMode && systemFavorites)
+ {
+ SystemFavoritesServiceLogError (wstring (L"The drive letter ") + (wchar_t) (drive + L'A') + wstring (L" used by favorite \"") + favorite.Path + L"\" is invalid.\nThis system favorite will not be mounted");
+ }
+ return FALSE;
+ }
mountOptions.ReadOnly = favorite.ReadOnly || userForcedReadOnly;
mountOptions.Removable = favorite.Removable;
if (favorite.UseLabelInExplorer && !favorite.Label.empty())
|