Skip to content

Commit

Permalink
Fix | Fix decrypt failure to drain data (dotnet#2618)
Browse files Browse the repository at this point in the history
  • Loading branch information
arellegue authored and dauinsight committed Aug 26, 2024
1 parent da57fa9 commit 02f14d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6139,6 +6139,12 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
// call to decrypt column keys has failed. The data wont be decrypted.
// Not setting the value to false, forces the driver to look for column value.
// Packet received from Key Vault will throws invalid token header.
if (stateObj.HasPendingData)
{
// Drain the pending data now if setting the HasPendingData to false.
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
DrainData(stateObj);
}
stateObj.HasPendingData = false;
}
throw SQL.ColumnDecryptionFailed(columnName, null, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6931,6 +6931,12 @@ internal bool TryReadSqlValue(SqlBuffer value,
// call to decrypt column keys has failed. The data wont be decrypted.
// Not setting the value to false, forces the driver to look for column value.
// Packet received from Key Vault will throws invalid token header.
if (stateObj.HasPendingData)
{
// Drain the pending data now if setting the HasPendingData to false.
// SqlDataReader.TryCloseInternal can not drain if HasPendingData = false.
DrainData(stateObj);
}
stateObj.HasPendingData = false;
}
throw SQL.ColumnDecryptionFailed(columnName, null, e);
Expand Down

0 comments on commit 02f14d2

Please sign in to comment.