Skip to content

Commit 766b72a

Browse files
authored
Fix | Fix decrypt failure to drain data (#2618)
1 parent 784046f commit 766b72a

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

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

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6935,6 +6935,12 @@ internal bool TryReadSqlValue(SqlBuffer value,
69356935
// call to decrypt column keys has failed. The data wont be decrypted.
69366936
// Not setting the value to false, forces the driver to look for column value.
69376937
// Packet received from Key Vault will throws invalid token header.
6938+
if (stateObj.HasPendingData)
6939+
{
6940+
// Drain the pending data now if setting the HasPendingData to false.
6941+
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
6942+
DrainData(stateObj);
6943+
}
69386944
stateObj.HasPendingData = false;
69396945
}
69406946
throw SQL.ColumnDecryptionFailed(columnName, null, e);

0 commit comments

Comments
 (0)