44
55using System;
66using System.Buffers;
7+ using System.Buffers.Binary;
78using System.Collections.Generic;
89using System.Data;
910using System.Data.SqlTypes;
@@ -4396,8 +4397,8 @@ private TdsOperationStatus TryProcessFedAuthInfo(TdsParserStateObject stateObj,
43964397 uint currentOptionOffset = checked(i * optionSize);
43974398
43984399 byte id = tokenData[currentOptionOffset];
4399- uint dataLen = BitConverter.ToUInt32 (tokenData, checked((int)(currentOptionOffset + 1)));
4400- uint dataOffset = BitConverter.ToUInt32 (tokenData, checked((int)(currentOptionOffset + 5)));
4400+ uint dataLen = BinaryPrimitives.ReadUInt32LittleEndian (tokenData.AsSpan( checked((int)(currentOptionOffset + 1) )));
4401+ uint dataOffset = BinaryPrimitives.ReadUInt32LittleEndian (tokenData.AsSpan( checked((int)(currentOptionOffset + 5) )));
44014402 if (SqlClientEventSource.Log.IsAdvancedTraceOn())
44024403 {
44034404 SqlClientEventSource.Log.AdvancedTraceEvent("<sc.TdsParser.TryProcessFedAuthInfo> FedAuthInfoOpt: ID={0}, DataLen={1}, Offset={2}", id, dataLen.ToString(CultureInfo.InvariantCulture), dataOffset.ToString(CultureInfo.InvariantCulture));
@@ -6824,7 +6825,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
68246825 return false;
68256826 }
68266827
6827- longValue = BitConverter.ToInt64 (unencryptedBytes, 0 );
6828+ longValue = BinaryPrimitives.ReadInt64LittleEndian (unencryptedBytes);
68286829
68296830 if (tdsType == TdsEnums.SQLBIT ||
68306831 tdsType == TdsEnums.SQLBITN)
@@ -6862,7 +6863,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
68626863 return false;
68636864 }
68646865
6865- singleValue = BitConverter.ToSingle( unencryptedBytes, 0 );
6866+ singleValue = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian( unencryptedBytes) );
68666867 value.Single = singleValue;
68676868 break;
68686869
@@ -6873,7 +6874,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
68736874 return false;
68746875 }
68756876
6876- doubleValue = BitConverter.ToDouble( unencryptedBytes, 0 );
6877+ doubleValue = BitConverter.Int64BitsToDouble(BinaryPrimitives.ReadInt64LittleEndian( unencryptedBytes) );
68776878 value.Double = doubleValue;
68786879 break;
68796880
@@ -6890,8 +6891,8 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
68906891 return false;
68916892 }
68926893
6893- mid = BitConverter.ToInt32 (unencryptedBytes, 0 );
6894- lo = BitConverter.ToUInt32 (unencryptedBytes, 4 );
6894+ mid = BinaryPrimitives.ReadInt32LittleEndian (unencryptedBytes);
6895+ lo = BinaryPrimitives.ReadUInt32LittleEndian (unencryptedBytes.AsSpan(4) );
68956896
68966897 long l = (((long)mid) << 0x20) + ((long)lo);
68976898 value.SetToMoney(l);
@@ -6928,8 +6929,8 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
69286929 return false;
69296930 }
69306931
6931- daypart = BitConverter.ToInt32 (unencryptedBytes, 0 );
6932- timepart = BitConverter.ToUInt32 (unencryptedBytes, 4 );
6932+ daypart = BinaryPrimitives.ReadInt32LittleEndian (unencryptedBytes);
6933+ timepart = BinaryPrimitives.ReadUInt32LittleEndian (unencryptedBytes.AsSpan(4) );
69336934 value.SetToDateTime(daypart, (int)timepart);
69346935 break;
69356936
0 commit comments