Ver código fonte

Bug 1380: Correct DST adjustments of FTP timestamps by IIS FTP server

https://winscp.net/tracker/1380

Source commit: 7e0d861c394d691bb2119f0d5e303dc0a06adc08
Martin Prikryl 9 anos atrás
pai
commit
4392420515
2 arquivos alterados com 13 adições e 0 exclusões
  1. 12 0
      source/core/FtpFileSystem.cpp
  2. 1 0
      source/core/FtpFileSystem.h

+ 12 - 0
source/core/FtpFileSystem.cpp

@@ -359,6 +359,7 @@ void __fastcall TFTPFileSystem::Open()
 
 
   TSessionData * Data = FTerminal->SessionData;
   TSessionData * Data = FTerminal->SessionData;
 
 
+  FWindowsServer = false;
   FTransferActiveImmediately = (Data->FtpTransferActiveImmediately == asOn);
   FTransferActiveImmediately = (Data->FtpTransferActiveImmediately == asOn);
 
 
   FSessionInfo.LoginTime = Now();
   FSessionInfo.LoginTime = Now();
@@ -3588,6 +3589,11 @@ void __fastcall TFTPFileSystem::HandleReplyStatus(UnicodeString Response)
           FTerminal->LogEvent(L"The server requires TLS/SSL handshake on transfer connection before responding 1yz to STOR/APPE");
           FTerminal->LogEvent(L"The server requires TLS/SSL handshake on transfer connection before responding 1yz to STOR/APPE");
           FTransferActiveImmediately = true;
           FTransferActiveImmediately = true;
         }
         }
+        if (ContainsText(FWelcomeMessage, L"Microsoft FTP Service"))
+        {
+          FTerminal->LogEvent(L"The server is probably running Windows, assuming that directory listing timestamps are affected by DST.");
+          FWindowsServer = true;
+        }
       }
       }
     }
     }
     else if (FLastCommand == PASS)
     else if (FLastCommand == PASS)
@@ -4354,6 +4360,12 @@ void __fastcall TFTPFileSystem::RemoteFileTimeToDateTimeAndPrecision(const TRemo
       // not exact as we got year as well, but it is most probably
       // not exact as we got year as well, but it is most probably
       // guessed by FZAPI anyway
       // guessed by FZAPI anyway
       ModificationFmt = Source.HasSeconds ? mfFull : mfMDHM;
       ModificationFmt = Source.HasSeconds ? mfFull : mfMDHM;
+
+      // With IIS, the Utc should be false only for MDTM
+      if (FWindowsServer && !Source.Utc)
+      {
+        DateTime -= DSTDifferenceForTime(DateTime);
+      }
     }
     }
     else
     else
     {
     {

+ 1 - 0
source/core/FtpFileSystem.h

@@ -272,6 +272,7 @@ private:
   X509 * FCertificate;
   X509 * FCertificate;
   EVP_PKEY * FPrivateKey;
   EVP_PKEY * FPrivateKey;
   bool FTransferActiveImmediately;
   bool FTransferActiveImmediately;
+  bool FWindowsServer;
   mutable UnicodeString FOptionScratch;
   mutable UnicodeString FOptionScratch;
 };
 };
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------