Skip to content

Commit 5195077

Browse files
Fix decrypt failure to drain data (#2818)
Co-authored-by: Aris Rellegue <134557572+arellegue@users.noreply.github.com>
1 parent 2eb0ed9 commit 5195077

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
@@ -6090,6 +6090,12 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
60906090
// call to decrypt column keys has failed. The data wont be decrypted.
60916091
// Not setting the value to false, forces the driver to look for column value.
60926092
// Packet received from Key Vault will throws invalid token header.
6093+
if (stateObj.HasPendingData)
6094+
{
6095+
// Drain the pending data now if setting the HasPendingData to false.
6096+
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
6097+
DrainData(stateObj);
6098+
}
60936099
stateObj.HasPendingData = false;
60946100
}
60956101
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
@@ -6910,6 +6910,12 @@ internal bool TryReadSqlValue(SqlBuffer value,
69106910
// call to decrypt column keys has failed. The data wont be decrypted.
69116911
// Not setting the value to false, forces the driver to look for column value.
69126912
// Packet received from Key Vault will throws invalid token header.
6913+
if (stateObj._pendingData)
6914+
{
6915+
// Drain the pending data now if setting the HasPendingData to false.
6916+
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
6917+
DrainData(stateObj);
6918+
}
69136919
stateObj._pendingData = false;
69146920
}
69156921
throw SQL.ColumnDecryptionFailed(columnName, null, e);

0 commit comments

Comments
 (0)