Browse Source

Bug fix: When reading input Stream in .NET assembly upload fails in 64-bit process, the transfer is not interrupted

Source commit: 5f7060355fcd15b6d610c0701389372f6bd85d55
Martin Prikryl 2 năm trước cách đây
mục cha
commit
5c7a4f3ab4

+ 1 - 1
dotnet/internal/ConsoleCommStruct.cs

@@ -96,7 +96,7 @@ namespace WinSCP
     {
         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20480)]
         public byte[] Data;
-        public UIntPtr Len;
+        public uint Len;
         [MarshalAs(UnmanagedType.I1)]
         public bool Error; // TransferIn only
     }

+ 1 - 1
dotnet/internal/ExeSessionProcess.cs

@@ -593,7 +593,7 @@ namespace WinSCP
                     int len = (int)e.Len;
                     len = StdIn.Read(e.Data, 0, len);
                     _logger.WriteLine("{0} bytes read", len);
-                    e.Len = (UIntPtr)len;
+                    e.Len = (uint)len;
                 }
                 catch (Exception ex)
                 {

+ 1 - 0
dotnet/internal/Logger.cs

@@ -376,6 +376,7 @@ namespace WinSCP
 #if NETSTANDARD
             WriteLine("Operating system information: {0} {1} {2}", RuntimeInformation.OSDescription, RuntimeInformation.OSArchitecture, RuntimeInformation.ProcessArchitecture);
 #endif
+            WriteLine("Bitness: {0}", Environment.Is64BitProcess ? "64-bit" : "32-bit");
             TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);
             WriteLine(
                 "Timezone: {0}; {1}",

+ 1 - 1
source/console/Console.h

@@ -77,7 +77,7 @@ struct TConsoleCommStruct
   struct TTransferEvent
   {
     unsigned char Data[20480];
-    size_t Len;
+    unsigned int Len;
     bool Error; // TRANSFERIN only
   };
 

+ 1 - 1
source/windows/ConsoleRunner.cpp

@@ -976,7 +976,7 @@ void __fastcall TExternalConsole::TransferOut(const unsigned char * Data, size_t
     try
     {
       CommStruct->Event = TConsoleCommStruct::TRANSFEROUT;
-      size_t BlockLen = std::min(Len - Offset, sizeof(CommStruct->TransferEvent.Data));
+      unsigned int BlockLen = std::min(Len - Offset, sizeof(CommStruct->TransferEvent.Data));
       memcpy(CommStruct->TransferEvent.Data, Data + Offset, BlockLen);
       CommStruct->TransferEvent.Len = BlockLen;
       Offset += BlockLen;