Skip to content

Commit 48f1b95

Browse files
committed
Throw better exception for protocol violation.
As soon as a malformed column_count packet is detected, throw a descriptive exception (instead of failing at an arbitrary point later during deserialization).
1 parent 6ff9177 commit 48f1b95

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/MySqlConnector/MySqlClient/Results/ResultSet.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior)
7979
{
8080
var reader = new ByteArrayReader(payload.ArraySegment);
8181
var columnCount = (int) reader.ReadLengthEncodedInteger();
82+
if (reader.BytesRemaining != 0)
83+
throw new MySqlException("Unexpected data at end of column_count packet; see https://github.com/mysql-net/MySqlConnector/issues/324");
84+
8285
ColumnDefinitions = new ColumnDefinitionPayload[columnCount];
8386
m_dataOffsets = new int[columnCount];
8487
m_dataLengths = new int[columnCount];

0 commit comments

Comments
 (0)