|
@@ -1025,7 +1025,7 @@ void __fastcall TSecureShell::UnregisterReceiveHandler(TNotifyEvent Handler)
|
|
|
FOnReceive = NULL;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall TSecureShell::FromBackend(bool IsStdErr, const unsigned char * Data, int Length)
|
|
|
+void __fastcall TSecureShell::FromBackend(const unsigned char * Data, int Length)
|
|
|
{
|
|
|
// Note that we do not apply ConvertFromPutty to Data yet (as opposite to CWrite).
|
|
|
// as there's no use for this atm.
|
|
@@ -1033,69 +1033,62 @@ void __fastcall TSecureShell::FromBackend(bool IsStdErr, const unsigned char * D
|
|
|
|
|
|
if (Configuration->ActualLogProtocol >= 1)
|
|
|
{
|
|
|
- LogEvent(FORMAT(L"Received %u bytes (%d)", (Length, int(IsStdErr))));
|
|
|
+ LogEvent(FORMAT(L"Received %u bytes", (Length)));
|
|
|
}
|
|
|
|
|
|
// Following is taken from scp.c from_backend() and modified
|
|
|
|
|
|
- if (IsStdErr)
|
|
|
- {
|
|
|
- AddStdError(ConvertInput(RawByteString(reinterpret_cast<const char *>(Data), Length)));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- const unsigned char *p = Data;
|
|
|
- unsigned Len = (unsigned)Length;
|
|
|
+ const unsigned char *p = Data;
|
|
|
+ unsigned Len = (unsigned)Length;
|
|
|
|
|
|
- // with event-select mechanism we can now receive data even before we
|
|
|
- // actually expect them (OutPtr can be NULL)
|
|
|
+ // with event-select mechanism we can now receive data even before we
|
|
|
+ // actually expect them (OutPtr can be NULL)
|
|
|
|
|
|
- if ((OutPtr != NULL) && (OutLen > 0) && (Len > 0))
|
|
|
- {
|
|
|
- unsigned Used = OutLen;
|
|
|
- if (Used > Len) Used = Len;
|
|
|
- memmove(OutPtr, p, Used);
|
|
|
- OutPtr += Used; OutLen -= Used;
|
|
|
- p += Used; Len -= Used;
|
|
|
- }
|
|
|
+ if ((OutPtr != NULL) && (OutLen > 0) && (Len > 0))
|
|
|
+ {
|
|
|
+ unsigned Used = OutLen;
|
|
|
+ if (Used > Len) Used = Len;
|
|
|
+ memmove(OutPtr, p, Used);
|
|
|
+ OutPtr += Used; OutLen -= Used;
|
|
|
+ p += Used; Len -= Used;
|
|
|
+ }
|
|
|
|
|
|
- if (Len > 0)
|
|
|
+ if (Len > 0)
|
|
|
+ {
|
|
|
+ if (PendSize < PendLen + Len)
|
|
|
{
|
|
|
- if (PendSize < PendLen + Len)
|
|
|
- {
|
|
|
- PendSize = PendLen + Len + 4096;
|
|
|
- Pending = (unsigned char *)
|
|
|
- (Pending ? srealloc(Pending, PendSize) : smalloc(PendSize));
|
|
|
- if (!Pending) FatalError(L"Out of memory");
|
|
|
- }
|
|
|
- memmove(Pending + PendLen, p, Len);
|
|
|
- PendLen += Len;
|
|
|
+ PendSize = PendLen + Len + 4096;
|
|
|
+ Pending = (unsigned char *)
|
|
|
+ (Pending ? srealloc(Pending, PendSize) : smalloc(PendSize));
|
|
|
+ if (!Pending) FatalError(L"Out of memory");
|
|
|
}
|
|
|
+ memmove(Pending + PendLen, p, Len);
|
|
|
+ PendLen += Len;
|
|
|
+ }
|
|
|
|
|
|
- if (FOnReceive != NULL)
|
|
|
+ if (FOnReceive != NULL)
|
|
|
+ {
|
|
|
+ if (!FFrozen)
|
|
|
{
|
|
|
- if (!FFrozen)
|
|
|
+ FFrozen = true;
|
|
|
+ try
|
|
|
{
|
|
|
- FFrozen = true;
|
|
|
- try
|
|
|
- {
|
|
|
- do
|
|
|
- {
|
|
|
- FDataWhileFrozen = false;
|
|
|
- FOnReceive(NULL);
|
|
|
- }
|
|
|
- while (FDataWhileFrozen);
|
|
|
- }
|
|
|
- __finally
|
|
|
+ do
|
|
|
{
|
|
|
- FFrozen = false;
|
|
|
+ FDataWhileFrozen = false;
|
|
|
+ FOnReceive(NULL);
|
|
|
}
|
|
|
+ while (FDataWhileFrozen);
|
|
|
}
|
|
|
- else
|
|
|
+ __finally
|
|
|
{
|
|
|
- FDataWhileFrozen = true;
|
|
|
+ FFrozen = false;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FDataWhileFrozen = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
@@ -1461,8 +1454,9 @@ int __fastcall TSecureShell::TranslateAuthenticationMessage(
|
|
|
return Result;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall TSecureShell::AddStdError(UnicodeString Str)
|
|
|
+void __fastcall TSecureShell::AddStdError(const char * Data, int Length)
|
|
|
{
|
|
|
+ UnicodeString Str = ConvertInput(RawByteString(Data, Length));
|
|
|
FStdError += Str;
|
|
|
|
|
|
Integer P;
|