• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision6723 (tree)
Time2017-05-12 21:44:01
Authordoda

Log Message

パスワード変更ダイアログの挙動調整

・フォーカスの初期位置を旧パスワード入力欄にした
・キャンセルした時に認証を試さず切断するようにした
・何も入力せずに Return を押した時の対策の為、空のパスワードを蹴るようにした

Change Summary

Incremental Difference

--- trunk/ttssh2/ttxssh/ssh.c (revision 6722)
+++ trunk/ttssh2/ttxssh/ssh.c (revision 6723)
@@ -7218,6 +7218,8 @@
72187218
72197219 static BOOL CALLBACK passwd_change_dialog(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
72207220 {
7221+ char old_passwd[PASSWD_MAXLEN];
7222+ char new_passwd[PASSWD_MAXLEN];
72217223 char retype_passwd[PASSWD_MAXLEN];
72227224 static struct change_password *cp;
72237225 LOGFONT logfont;
@@ -7262,30 +7264,44 @@
72627264 UTIL_get_lang_msg("DLG_PASSCHG_CONFIRMPASSWD", pvar, uimsg);
72637265 SetDlgItemText(dlg, IDC_CONFIRM_PASSWD_LABEL, pvar->ts->UIMsg);
72647266
7265- return TRUE;
7267+ SetFocus(GetDlgItem(dlg, IDC_OLD_PASSWD));
72667268
7269+ return FALSE;
7270+
72677271 case WM_COMMAND:
72687272 switch (LOWORD(wParam)) {
72697273 case IDOK:
7270- SendMessage(GetDlgItem(dlg, IDC_OLD_PASSWD), WM_GETTEXT , sizeof(cp->passwd), (LPARAM)cp->passwd);
7271- SendMessage(GetDlgItem(dlg, IDC_NEW_PASSWD), WM_GETTEXT , sizeof(cp->new_passwd), (LPARAM)cp->new_passwd);
7274+ SendMessage(GetDlgItem(dlg, IDC_OLD_PASSWD), WM_GETTEXT , sizeof(old_passwd), (LPARAM)old_passwd);
7275+ SendMessage(GetDlgItem(dlg, IDC_NEW_PASSWD), WM_GETTEXT , sizeof(new_passwd), (LPARAM)new_passwd);
72727276 SendMessage(GetDlgItem(dlg, IDC_CONFIRM_PASSWD), WM_GETTEXT , sizeof(retype_passwd), (LPARAM)retype_passwd);
72737277
7274- if (strcmp(cp->new_passwd, retype_passwd) == 0) {
7275- EndDialog(dlg, 1); // dialog close
7278+ if (strcmp(new_passwd, retype_passwd) == 1) {
7279+ UTIL_get_lang_msg("MSG_PASSCHG_MISMATCH", pvar, "Mismatch; try again.");
7280+ MessageBox(NULL, pvar->ts->UIMsg, "ERROR", MB_OK | MB_ICONEXCLAMATION);
7281+ return FALSE;
7282+ }
72767283
7277- if (DlgChgPassFont != NULL) {
7278- DeleteObject(DlgChgPassFont);
7279- DlgChgPassFont = NULL;
7280- }
7284+ if (old_passwd[0] == 0 || new_passwd[0] == 0) {
7285+ // ダイアログを開いてすぐに Return を押してしまった時の対策の為、
7286+ // とりあえず空パスワードをはじいておく。
7287+ return FALSE;
7288+ }
72817289
7282- return TRUE;
7283- }
7284- UTIL_get_lang_msg("MSG_PASSCHG_MISMATCH", pvar, "Mismatch; try again.");
7285- MessageBox(NULL, pvar->ts->UIMsg, "ERROR", MB_OK | MB_ICONEXCLAMATION);
7286- return FALSE;
7290+ strncpy_s(cp->passwd, sizeof(cp->passwd), old_passwd, _TRUNCATE);
7291+ strncpy_s(cp->new_passwd, sizeof(cp->new_passwd), new_passwd, _TRUNCATE);
72877292
7293+ EndDialog(dlg, 1); // dialog close
7294+
7295+ if (DlgChgPassFont != NULL) {
7296+ DeleteObject(DlgChgPassFont);
7297+ DlgChgPassFont = NULL;
7298+ }
7299+
7300+ return TRUE;
7301+
72887302 case IDCANCEL:
7303+ // 接続を切る
7304+ notify_closed_connection(pvar, "authentication cancelled");
72897305 EndDialog(dlg, 0); // dialog close
72907306
72917307 if (DlgChgPassFont != NULL) {
@@ -7302,7 +7318,7 @@
73027318
73037319 BOOL handle_SSH2_userauth_passwd_changereq(PTInstVar pvar)
73047320 {
7305- int len;
7321+ int len, ret;
73067322 char *data;
73077323 buffer_t *msg = NULL;
73087324 char *s, *username;
@@ -7314,9 +7330,19 @@
73147330
73157331 notify_verbose_message(pvar, "SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ was received.", LOG_LEVEL_VERBOSE);
73167332
7333+ memset(&cp, 0, sizeof(cp));
73177334 cp.pvar = pvar;
7318- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHPASSWD_INPUT), pvar->cv->HWin, passwd_change_dialog, (LPARAM)&cp);
7335+ ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHPASSWD_INPUT), pvar->cv->HWin, passwd_change_dialog, (LPARAM)&cp);
73197336
7337+ if (ret == -1) {
7338+ logprintf(pvar, LOG_LEVEL_WARNING, __FUNCTION__ "%s: DialogBoxParam failed.");
7339+ return FALSE;
7340+ }
7341+ else if (ret == 0) {
7342+ logprintf(pvar, LOG_LEVEL_NOTICE, __FUNCTION__ "%s: dialog cancelled.");
7343+ return FALSE;
7344+ }
7345+
73207346 // 6byte(サイズ+パディング+タイプ)を取り除いた以降のペイロード
73217347 data = pvar->ssh_state.payload;
73227348 // パケットサイズ - (パディングサイズ+1);真のパケットサイズ
Show on old repository browser