Skip to content

Commit a985927

Browse files
authored
[5.2.2] | Fix decrypt failure to drain data (#2618) (#2817)
1 parent c7de60b commit a985927

File tree

2 files changed

+12
-0
lines changed
  • src/Microsoft.Data.SqlClient

2 files changed

+12
-0
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

+6
Original file line numberDiff line numberDiff line change
@@ -6139,6 +6139,12 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
61396139
// call to decrypt column keys has failed. The data wont be decrypted.
61406140
// Not setting the value to false, forces the driver to look for column value.
61416141
// Packet received from Key Vault will throws invalid token header.
6142+
if (stateObj.HasPendingData)
6143+
{
6144+
// Drain the pending data now if setting the HasPendingData to false.
6145+
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
6146+
DrainData(stateObj);
6147+
}
61426148
stateObj.HasPendingData = false;
61436149
}
61446150
throw SQL.ColumnDecryptionFailed(columnName, null, e);

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

+6
Original file line numberDiff line numberDiff line change
@@ -6931,6 +6931,12 @@ internal bool TryReadSqlValue(SqlBuffer value,
69316931
// call to decrypt column keys has failed. The data wont be decrypted.
69326932
// Not setting the value to false, forces the driver to look for column value.
69336933
// Packet received from Key Vault will throws invalid token header.
6934+
if (stateObj.HasPendingData)
6935+
{
6936+
// Drain the pending data now if setting the HasPendingData to false.
6937+
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
6938+
DrainData(stateObj);
6939+
}
69346940
stateObj.HasPendingData = false;
69356941
}
69366942
throw SQL.ColumnDecryptionFailed(columnName, null, e);

0 commit comments

Comments
 (0)