4
4
5
5
using System;
6
6
using System.Buffers;
7
+ using System.Buffers.Binary;
7
8
using System.Collections.Generic;
8
9
using System.Data;
9
10
using System.Data.SqlTypes;
@@ -4403,8 +4404,8 @@ private TdsOperationStatus TryProcessFedAuthInfo(TdsParserStateObject stateObj,
4403
4404
uint currentOptionOffset = checked(i * optionSize);
4404
4405
4405
4406
byte id = tokenData[currentOptionOffset];
4406
- uint dataLen = BitConverter.ToUInt32 (tokenData, checked((int)(currentOptionOffset + 1)));
4407
- uint dataOffset = BitConverter.ToUInt32 (tokenData, checked((int)(currentOptionOffset + 5)));
4407
+ uint dataLen = BinaryPrimitives.ReadUInt32LittleEndian (tokenData.AsSpan( checked((int)(currentOptionOffset + 1) )));
4408
+ uint dataOffset = BinaryPrimitives.ReadUInt32LittleEndian (tokenData.AsSpan( checked((int)(currentOptionOffset + 5) )));
4408
4409
if (SqlClientEventSource.Log.IsAdvancedTraceOn())
4409
4410
{
4410
4411
SqlClientEventSource.Log.AdvancedTraceEvent("<sc.TdsParser.TryProcessFedAuthInfo> FedAuthInfoOpt: ID={0}, DataLen={1}, Offset={2}", id, dataLen.ToString(CultureInfo.InvariantCulture), dataOffset.ToString(CultureInfo.InvariantCulture));
@@ -6830,7 +6831,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
6830
6831
return false;
6831
6832
}
6832
6833
6833
- longValue = BitConverter.ToInt64 (unencryptedBytes, 0 );
6834
+ longValue = BinaryPrimitives.ReadInt64LittleEndian (unencryptedBytes);
6834
6835
6835
6836
if (tdsType == TdsEnums.SQLBIT ||
6836
6837
tdsType == TdsEnums.SQLBITN)
@@ -6868,7 +6869,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
6868
6869
return false;
6869
6870
}
6870
6871
6871
- singleValue = BitConverter.ToSingle( unencryptedBytes, 0 );
6872
+ singleValue = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian( unencryptedBytes) );
6872
6873
value.Single = singleValue;
6873
6874
break;
6874
6875
@@ -6879,7 +6880,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
6879
6880
return false;
6880
6881
}
6881
6882
6882
- doubleValue = BitConverter.ToDouble( unencryptedBytes, 0 );
6883
+ doubleValue = BitConverter.Int64BitsToDouble(BinaryPrimitives.ReadInt64LittleEndian( unencryptedBytes) );
6883
6884
value.Double = doubleValue;
6884
6885
break;
6885
6886
@@ -6896,8 +6897,8 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
6896
6897
return false;
6897
6898
}
6898
6899
6899
- mid = BitConverter.ToInt32 (unencryptedBytes, 0 );
6900
- lo = BitConverter.ToUInt32 (unencryptedBytes, 4 );
6900
+ mid = BinaryPrimitives.ReadInt32LittleEndian (unencryptedBytes);
6901
+ lo = BinaryPrimitives.ReadUInt32LittleEndian (unencryptedBytes.AsSpan(4) );
6901
6902
6902
6903
long l = (((long)mid) << 0x20) + ((long)lo);
6903
6904
value.SetToMoney(l);
@@ -6934,8 +6935,8 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
6934
6935
return false;
6935
6936
}
6936
6937
6937
- daypart = BitConverter.ToInt32 (unencryptedBytes, 0 );
6938
- timepart = BitConverter.ToUInt32 (unencryptedBytes, 4 );
6938
+ daypart = BinaryPrimitives.ReadInt32LittleEndian (unencryptedBytes);
6939
+ timepart = BinaryPrimitives.ReadUInt32LittleEndian (unencryptedBytes.AsSpan(4) );
6939
6940
value.SetToDateTime(daypart, (int)timepart);
6940
6941
break;
6941
6942
0 commit comments