From 9169e6ed023ea24bf30b7ce640ffb471236e2e6f Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 22 Dec 2008 19:16:07 -0800 Subject: [PATCH] cryptui: Make sure input file is not empty. --- dlls/cryptui/cryptui_En.rc | 1 + dlls/cryptui/cryptuires.h | 1 + dlls/cryptui/main.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/dlls/cryptui/cryptui_En.rc b/dlls/cryptui/cryptui_En.rc index 470eb1f36a4..9f42d2ecf67 100644 --- a/dlls/cryptui/cryptui_En.rc +++ b/dlls/cryptui/cryptui_En.rc @@ -76,6 +76,7 @@ STRINGTABLE DISCARDABLE IDS_IMPORT_FILTER_SERIALIZED_STORE "Microsoft Serialized Certificate Store (*.sst)" IDS_IMPORT_FILTER_CMS "CMS/PKCS #7 Messages (*.spc; *.p7b)" IDS_IMPORT_FILTER_ALL "All Files (*.*)" + IDS_IMPORT_EMPTY_FILE "Please select a file." IDS_PURPOSE_SERVER_AUTH "Ensures the identify of a remote computer" IDS_PURPOSE_CLIENT_AUTH "Proves your identity to a remote computer" IDS_PURPOSE_CODE_SIGNING "Ensures software came from software publisher\nProtects software from alteration after publication" diff --git a/dlls/cryptui/cryptuires.h b/dlls/cryptui/cryptuires.h index 9abfe4956f7..b5883a6d1db 100644 --- a/dlls/cryptui/cryptuires.h +++ b/dlls/cryptui/cryptuires.h @@ -73,6 +73,7 @@ #define IDS_IMPORT_FILTER_SERIALIZED_STORE 1053 #define IDS_IMPORT_FILTER_CMS 1054 #define IDS_IMPORT_FILTER_ALL 1055 +#define IDS_IMPORT_EMPTY_FILE 1056 #define IDS_PURPOSE_SERVER_AUTH 1100 #define IDS_PURPOSE_CLIENT_AUTH 1101 diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c index c37c6aaaa19..23efa075304 100644 --- a/dlls/cryptui/main.c +++ b/dlls/cryptui/main.c @@ -3529,7 +3529,8 @@ static BOOL check_context_type(DWORD dwFlags, DWORD type) } -static void import_warn_type_mismatch(DWORD dwFlags, HWND hwnd, LPCWSTR szTitle) +static void import_warning(DWORD dwFlags, HWND hwnd, LPCWSTR szTitle, + int warningID) { if (!(dwFlags & CRYPTUI_WIZ_NO_UI)) { @@ -3544,12 +3545,17 @@ static void import_warn_type_mismatch(DWORD dwFlags, HWND hwnd, LPCWSTR szTitle) sizeof(title) / sizeof(title[0])); pTitle = title; } - LoadStringW(hInstance, IDS_IMPORT_TYPE_MISMATCH, error, + LoadStringW(hInstance, warningID, error, sizeof(error) / sizeof(error[0])); MessageBoxW(hwnd, error, pTitle, MB_ICONERROR | MB_OK); } } +static void import_warn_type_mismatch(DWORD dwFlags, HWND hwnd, LPCWSTR szTitle) +{ + import_warning(dwFlags, hwnd, szTitle, IDS_IMPORT_TYPE_MISMATCH); +} + static BOOL check_store_context_type(DWORD dwFlags, HCERTSTORE store) { BOOL ret; @@ -3765,6 +3771,7 @@ static WCHAR *make_import_file_filter(DWORD dwFlags) struct ImportWizData { DWORD dwFlags; + LPCWSTR pwszWizardTitle; PCCRYPTUI_WIZ_IMPORT_SRC_INFO pImportSrc; HCERTSTORE hDestCertStore; }; @@ -3796,6 +3803,30 @@ static LRESULT CALLBACK import_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, PSWIZB_BACK | PSWIZB_NEXT); ret = TRUE; break; + case PSN_WIZNEXT: + { + HWND fileNameEdit = GetDlgItem(hwnd, IDC_IMPORT_FILENAME); + DWORD len = SendMessageW(fileNameEdit, WM_GETTEXTLENGTH, 0, 0); + + data = (struct ImportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + if (!len) + { + import_warning(data->dwFlags, hwnd, data->pwszWizardTitle, + IDS_IMPORT_EMPTY_FILE); + SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, 1); + ret = 1; + } + else + { + LPWSTR fileName = HeapAlloc(GetProcessHeap(), 0, + (len + 1) * sizeof(WCHAR)); + + SendMessageW(fileNameEdit, WM_GETTEXT, len + 1, + (LPARAM)fileName); + FIXME("validate %s\n", debugstr_w(fileName)); + } + break; + } } break; } @@ -3883,7 +3914,8 @@ static BOOL show_import_ui(DWORD dwFlags, HWND hwndParent, { PROPSHEETHEADERW hdr; PROPSHEETPAGEW pages[4]; - struct ImportWizData data = { dwFlags, pImportSrc, hDestCertStore }; + struct ImportWizData data = { dwFlags, pwszWizardTitle, pImportSrc, + hDestCertStore }; FIXME("\n"); -- 2.11.4.GIT