Răsfoiți Sursa

Bug 1818: Ignore incorrect timestamps in MDTM response, while autodetecting timezone difference

https://winscp.net/tracker/1818

Source commit: 1d22239c618e5bd2c4079ce295efe56ab24f8067
Martin Prikryl 5 ani în urmă
părinte
comite
e82e3441db
1 a modificat fișierele cu 7 adăugiri și 0 ștergeri
  1. 7 0
      source/core/FtpFileSystem.cpp

+ 7 - 0
source/core/FtpFileSystem.cpp

@@ -2114,6 +2114,7 @@ void __fastcall TFTPFileSystem::AutoDetectTimeDifference(TRemoteFileList * FileL
           // and using LIST (no conversion, expecting the server uses the same timezone as the client).
           // Note that FormatTimeZone reverses the value.
           FTimeDifference = static_cast<__int64>(SecsPerDay * (UtcModification - File->Modification));
+          double Hours = TTimeSpan::FromSeconds(FTimeDifference).TotalHours;
 
           UnicodeString FileLog =
             FORMAT(L"%s (Listing: %s, UTC: %s)", (File->FullFileName, StandardTimestamp(File->Modification), StandardTimestamp(UtcModification)));
@@ -2122,6 +2123,12 @@ void __fastcall TFTPFileSystem::AutoDetectTimeDifference(TRemoteFileList * FileL
           {
             LogMessage = FORMAT(L"No timezone difference detected using file %s", (FileLog));
           }
+          // Seen with "GamingDeluxe FTP Server", which returns "213 00010101000000"
+          else if (fabs(Hours) >= 48)
+          {
+            FTimeDifference = 0;
+            LogMessage = FORMAT(L"Ignoring suspicious timezone difference of %s hours, detected using file %s", (IntToStr(__int64(Hours)), FileLog));
+          }
           else
           {
             LogMessage = FORMAT(L"Timezone difference of %s detected using file %s", (FormatTimeZone(FTimeDifference), FileLog));