Skip to content

Commit 2bfbcf0

Browse files
Fix CA2022: Avoid inexact read with Stream.Read
1 parent 900ab60 commit 2bfbcf0

File tree

1 file changed

+7
-3
lines changed
  • dotnet/src/dotnetframework/GxClasses/Domain

1 file changed

+7
-3
lines changed

dotnet/src/dotnetframework/GxClasses/Domain/GxFtp.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,13 @@ private bool IsCompleteResponse(Stream responseStream)
847847
{
848848
int StatusCode=-1;
849849
Byte[] ByteArray = new Byte[responselength];
850-
String statuscodestr;
851-
responseStream.Read(ByteArray,0,responselength);
852-
statuscodestr=Encoding.ASCII.GetString(ByteArray,0,responselength);
850+
String statuscodestr;
851+
#if NETCORE
852+
responseStream.ReadExactly(ByteArray,0,responselength);
853+
#else
854+
responseStream.Read(ByteArray, 0, responselength);
855+
#endif
856+
statuscodestr = Encoding.ASCII.GetString(ByteArray,0,responselength);
853857
if (responselength==5 && ByteArray[responselength-1] == '\n')
854858
{
855859

0 commit comments

Comments
 (0)