瀏覽代碼

Merge branch 'master' into dev

# Conflicts:
#	source/WinSCP.cbproj

Source commit: 85c8b994f82ae78c83d11d7208a16bd489cfd921
Martin Prikryl 5 年之前
父節點
當前提交
be26803f86

+ 1 - 1
libs/openssl/Makefile

@@ -21,7 +21,7 @@ CFLAG= \
     -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_SEED -DOPENSSL_NO_RC5 -DOPENSSL_NO_MDC2 \
     -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_KRB5 -DOPENSSL_NO_ENGINE -DOPENSSL_NO_DYNAMIC_ENGINE \
     -DOPENSSL_DISABLE_OLD_DES_SUPPORT -DNO_CHMOD -DOPENSSL_NO_DGRAM -DDOPENSSL_NO_EC_NISTP_64_GCC_128 \
-    -DOPENSSL_NO_WHIRLPOOL -DPBE_UNICODE -DWINSCP -DMK1MF_BUILD -DMK1MF_PLATFORM_BC_NT \
+    -DOPENSSL_NO_WHIRLPOOL -DWINSCP -DMK1MF_BUILD -DMK1MF_PLATFORM_BC_NT \
     -DOPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
 LIB_CFLAG=
 

+ 0 - 8
libs/openssl/crypto/evp/evp_pbe.c

@@ -104,15 +104,7 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
     if (!pass)
         passlen = 0;
     else if (passlen == -1)
-    {
-    #if defined(WINSCP) && defined(PBE_UNICODE)
-        // OPENSSL_asc2uni adds the trailing \0 to the length,
-        // even if input ascii password length does not include it
-        passlen = (wcslen((const wchar_t*)pass) * sizeof(wchar_t)) + sizeof(wchar_t);
-    #else
         passlen = strlen(pass);
-    #endif
-    }
 
     if (cipher_nid == -1)
         cipher = NULL;

+ 0 - 26
libs/openssl/crypto/pkcs12/p12_key.c

@@ -27,32 +27,6 @@ void h__dump(unsigned char *p, int len);
 # define min(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
-#if defined(WINSCP) && defined(PBE_UNICODE)
-#undef PKCS12_key_gen_uni
-
-int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
-                       int saltlen, int id, int iter, int n,
-                       unsigned char *out, const EVP_MD *md_type);
-
-int PKCS12_key_gen_wrap(unsigned char *pass, int passlen, unsigned char *salt,
-                        int saltlen, int id, int iter, int n,
-                        unsigned char *out, const EVP_MD *md_type)
-{
-    if (pass == NULL)
-    {
-        // noop
-    }
-    // PKCS12_key_gen_uni cannot handle -1 length (contrary to PKCS12_key_gen_asc).
-    // OPENSSL_asc2uni adds the trailing \0 to the length,
-    // even if input ascii password length does not include it.
-    else if (passlen < 0)
-    {
-        passlen = (wcslen((wchar_t*)pass) * sizeof(wchar_t)) + sizeof(wchar_t);
-    }
-    return PKCS12_key_gen_uni(pass, passlen, salt, saltlen, id, iter, n, out, md_type);
-}
-#endif
-
 int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
                        int saltlen, int id, int iter, int n,
                        unsigned char *out, const EVP_MD *md_type)

+ 1 - 11
libs/openssl/crypto/pkcs12/p12_kiss.c

@@ -57,21 +57,11 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
      * password are two different things...
      */
 
-    if (!pass ||
-        (!pass[0]
-        #if defined(WINSCP) && defined(PBE_UNICODE)
-        && !pass[1]
-        #endif
-        )) {
+    if (!pass || !*pass) {
         if (PKCS12_verify_mac(p12, NULL, 0))
             pass = NULL;
-        #if defined(WINSCP) && defined(PBE_UNICODE)
-        else if (PKCS12_verify_mac(p12, "\0", -1))
-            pass = "\0"; // two NULLs
-        #else
         else if (PKCS12_verify_mac(p12, "", 0))
             pass = "";
-        #endif
         else {
             PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_MAC_VERIFY_FAILURE);
             goto err;

+ 2 - 0
source/components/UnixDriveView.cpp

@@ -70,6 +70,8 @@ void __fastcall TCustomUnixDriveView::CreateWnd()
   TCustomDriveView::CreateWnd();
 
   FDragDropFilesEx->TargetEffects = TDropEffectSet() << deCopy << deMove;
+  // in case the items were recreated
+  FPrevSelected = Selected;
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomUnixDriveView::SetTerminal(TTerminal * value)

+ 2 - 9
source/core/Common.cpp

@@ -3282,17 +3282,10 @@ void __fastcall ParseCertificate(const UnicodeString & Path,
 
   if (Pkcs12 != NULL)
   {
-    // Modeled after OPENSSL_asc2uni (reversed bitness to what UnicodeString/wchar_t use)
-    std::vector<char> Buf;
-    Buf.resize(Passphrase.Length() * sizeof(wchar_t) + sizeof(wchar_t));
-    for (int Index = 0; Index <= Passphrase.Length(); Index++)
-    {
-      Buf[(Index * 2)] = (Passphrase.c_str()[Index] >> 8);
-      Buf[(Index * 2) + 1] = (Passphrase.c_str()[Index] & 0x00FF);
-    }
+    UTF8String PassphraseUtf(Passphrase);
 
     bool Result =
-      (PKCS12_parse(Pkcs12, &Buf[0], &PrivateKey, &Certificate, NULL) == 1);
+      (PKCS12_parse(Pkcs12, PassphraseUtf.c_str(), &PrivateKey, &Certificate, NULL) == 1);
     PKCS12_free(Pkcs12);
 
     if (!Result)

+ 1 - 1
source/forms/CustomScpExplorer.cpp

@@ -4954,7 +4954,7 @@ void __fastcall TCustomScpExplorerForm::FormCloseQuery(TObject * /*Sender*/,
 
       SetFocus();
       Result = MessageDialog(Message, qtConfirmation,
-        Answers, HELP_NONE, &Params);
+        Answers, HELP_CLOSE_SESSION_WORKSPACE, &Params);
 
       if (Result == qaNeverAskAgain)
       {

+ 2 - 1
source/forms/NonVisual.cpp

@@ -1065,8 +1065,9 @@ int __fastcall TNonVisualDataModule::CreateCustomCommandsListMenu(
         UnicodeString Name = ExtractFileName(Command->Id);
         if (Name.IsEmpty())
         {
-          Name = MakeIdent(Command->Name);
+          Name = Command->Name;
         }
+        Name = MakeIdent(Name);
         Name += L"CustomCommand";
         // This is only the last resort to avoid run-time errors.
         // If there are duplicates, button hidding won't be deterministic.

+ 1 - 0
source/forms/SiteAdvanced.cpp

@@ -1043,6 +1043,7 @@ void __fastcall TSiteAdvancedDialog::UpdateControls()
     SslSheet->Enabled = Ssl;
     // TLS/SSL session reuse is not configurable for WebDAV/S3 yet
     SslSessionReuseCheck->Enabled = SslSheet->Enabled && FtpProtocol;
+    TlsAuthenticationGroup->Visible = Ssl && (FtpProtocol || WebDavProtocol);
 
     // encryption sheet
     EncryptionSheet->Enabled = SftpProtocol;

+ 3 - 1
source/putty/mainchan.c

@@ -207,8 +207,10 @@ static void mainchan_try_fallback_command(mainchan *mc)
     const char *cmd = conf_get_str(mc->conf, CONF_remote_cmd2);
     if (conf_get_bool(mc->conf, CONF_ssh_subsys2)) {
         sshfwd_start_subsystem(mc->sc, true, cmd);
-    } else {
+    } else if (*cmd) {
         sshfwd_start_command(mc->sc, true, cmd);
+    } else {
+        sshfwd_start_shell(mc->sc, true); // WINSCP
     }
     mc->req_cmd_fallback = true;
 }

+ 6 - 0
source/putty/putty.h

@@ -2283,4 +2283,10 @@ void pktin_free_queue_callback(void *vctx);
 #define WINSCP_BOM "\xEF\xBB\xBF"
 #endif
 
+#ifdef _DEBUG
+#undef assert
+void DoAssertC(char * Message, char * Filename, int LineNumber);
+#define assert(p) ((p) ? (void)0 : DoAssertC(TEXT(#p), TEXT(__FILE__), __LINE__))
+#endif
+
 #endif

+ 1 - 0
source/resource/HelpWin.h

@@ -67,5 +67,6 @@
 #define HELP_AUTOMATIC_UPDATE        "updates#automatic_upgrade"
 #define HELP_SITE_RAW                "ui_login_raw"
 #define HELP_PUTTY_SETTINGS          "ui_login_environment#putty"
+#define HELP_CLOSE_SESSION_WORKSPACE "workspace"
 
 #endif // TextsWin

+ 40 - 11
source/windows/VCLCommon.cpp

@@ -1487,9 +1487,23 @@ int CALLBACK PathWordBreakProc(wchar_t * Ch, int Current, int Len, int Code)
   return Result;
 }
 //---------------------------------------------------------------------------
-static void __fastcall PathWordBreakEditWindowProc(void * Data, TMessage & Message)
+class TPathWordBreakProcComponent : public TComponent
 {
-  TCustomEdit * Edit = static_cast<TCustomEdit *>(Data);
+public:
+  __fastcall TPathWordBreakProcComponent() :
+    TComponent(NULL)
+  {
+  }
+
+  void __fastcall PathWordBreakEditWindowProc(TMessage & Message);
+
+  TWinControl * WinControl;
+  TWndMethod PrevWindowProc;
+};
+//---------------------------------------------------------------------------
+void __fastcall TPathWordBreakProcComponent::PathWordBreakEditWindowProc(TMessage & Message)
+{
+  bool Handled = false;
   if (Message.Msg == WM_CHAR)
   {
     // Ctrl+Backspace
@@ -1498,7 +1512,8 @@ static void __fastcall PathWordBreakEditWindowProc(void * Data, TMessage & Messa
     TWMChar & CharMessage = *reinterpret_cast<TWMChar *>(&Message);
     if (CharMessage.CharCode == '\x7F')
     {
-      TCustomComboBox * ComboBox = static_cast<TCustomComboBox *>(Data);
+      TCustomEdit * Edit = dynamic_cast<TCustomEdit *>(WinControl);
+      TCustomComboBox * ComboBox = dynamic_cast<TCustomComboBox *>(WinControl);
 
       if (((Edit != NULL) && (Edit->SelLength == 0)) ||
           ((ComboBox != NULL) && (ComboBox->SelLength == 0)))
@@ -1512,25 +1527,30 @@ static void __fastcall PathWordBreakEditWindowProc(void * Data, TMessage & Messa
         NewKeyState[VK_SHIFT] = 0x81;
         SetKeyboardState(NewKeyState);
 
-        SendMessage(Edit->Handle, WM_KEYDOWN, VK_LEFT, 1);
+        SendMessage(WinControl->Handle, WM_KEYDOWN, VK_LEFT, 1);
         NewKeyState[VK_SHIFT] = 0;
         NewKeyState[VK_CONTROL] = 0;
         SetKeyboardState(NewKeyState);
 
-        SendMessage(Edit->Handle, WM_KEYDOWN, VK_DELETE, 1);
+        SendMessage(WinControl->Handle, WM_KEYDOWN, VK_DELETE, 1);
         SetKeyboardState(KeyState);
       }
       Message.Result = 1;
+      Handled = true;
+    }
+  }
+
+  if (!Handled)
+  {
+    if (PrevWindowProc != NULL)
+    {
+      PrevWindowProc(Message);
     }
     else
     {
-      ControlWndProc(Edit)(Message);
+      ControlWndProc(WinControl)(Message);
     }
   }
-  else
-  {
-    ControlWndProc(Edit)(Message);
-  }
 }
 //---------------------------------------------------------------------------
 class TPublicCustomCombo : public TCustomCombo
@@ -1558,7 +1578,16 @@ void __fastcall InstallPathWordBreakProc(TWinControl * Control)
   }
   SendMessage(Wnd, EM_SETWORDBREAKPROC, 0, (LPARAM)(EDITWORDBREAKPROC)PathWordBreakProc);
 
-  Control->WindowProc = MakeMethod<TWndMethod>(Control, PathWordBreakEditWindowProc);
+  TPathWordBreakProcComponent * PathWordBreakProcComponent = new TPathWordBreakProcComponent();
+  PathWordBreakProcComponent->Name = TPathWordBreakProcComponent::QualifiedClassName();
+  Control->InsertComponent(PathWordBreakProcComponent);
+  PathWordBreakProcComponent->WinControl = Control;
+  // Have to remember the proc because of TTBEditItemViewer.EditWndProc
+  PathWordBreakProcComponent->PrevWindowProc =
+    // Test is probably redundant, it's there to limit impact of the change.
+    ((Control->WindowProc != ControlWndProc(Control)) ? Control->WindowProc : TWndMethod());
+
+  Control->WindowProc = PathWordBreakProcComponent->PathWordBreakEditWindowProc;
 }
 //---------------------------------------------------------------------------
 static void __fastcall RemoveHiddenControlsFromOrder(TControl ** ControlsOrder, int & Count)