@@ -193,6 +193,56 @@ static void test_unknown_message_disconnects() {
193193 ok (sd.events_read == 1 , " unknown: events_read NOT incremented" );
194194}
195195
196+ /* *
197+ * @brief Malformed bootstrap trxid ranges disconnect without counting an event.
198+ */
199+ static void test_malformed_bootstrap_disconnects () {
200+ GTID_Server_Data sd (nullptr , (char *)" 127.0.0.1" , 0 , 3306 );
201+
202+ std::string msg = std::string (" ST=" ) + UUID_A + " :abc\n " ;
203+ stuff_buffer (sd, msg);
204+
205+ ok (sd.read_next_gtid () == false , " malformed ST: returns false" );
206+ ok (sd.active == false , " malformed ST: active set to false" );
207+ ok (sd.events_read == 0 , " malformed ST: events_read NOT incremented" );
208+ ok (sd.gtid_exists ((char *)UUID_A_STRIPPED , 0 ) == false , " malformed ST: trxid 0 was not added" );
209+ }
210+
211+ /* *
212+ * @brief Malformed I3 trxid ranges disconnect without counting an event.
213+ */
214+ static void test_malformed_i3_disconnects () {
215+ GTID_Server_Data sd (nullptr , (char *)" 127.0.0.1" , 0 , 3306 );
216+
217+ std::string msg = std::string (" I3=" ) + UUID_A_STRIPPED + " :10-abc\n " ;
218+ stuff_buffer (sd, msg);
219+
220+ ok (sd.read_next_gtid () == false , " malformed I3: returns false" );
221+ ok (sd.active == false , " malformed I3: active set to false" );
222+ ok (sd.events_read == 0 , " malformed I3: events_read NOT incremented" );
223+ ok (sd.gtid_exists ((char *)UUID_A_STRIPPED , 0 ) == false , " malformed I3: trxid 0 was not added" );
224+ ok (sd.gtid_exists ((char *)UUID_A_STRIPPED , 10 ) == false , " malformed I3: trxid 10 was not added" );
225+ }
226+
227+ /* *
228+ * @brief Malformed I4 trxid ranges disconnect and preserve earlier event count.
229+ */
230+ static void test_malformed_i4_disconnects () {
231+ GTID_Server_Data sd (nullptr , (char *)" 127.0.0.1" , 0 , 3306 );
232+
233+ std::string msg1 = std::string (" I3=" ) + UUID_B_STRIPPED + " :10-20\n " ;
234+ stuff_buffer (sd, msg1);
235+ sd.read_next_gtid ();
236+
237+ std::string msg2 = " I4=30-40x\n " ;
238+ stuff_buffer (sd, msg2);
239+
240+ ok (sd.read_next_gtid () == false , " malformed I4: returns false" );
241+ ok (sd.active == false , " malformed I4: active set to false" );
242+ ok (sd.events_read == 1 , " malformed I4: events_read NOT incremented" );
243+ ok (sd.gtid_exists ((char *)UUID_B_STRIPPED , 30 ) == false , " malformed I4: trxid 30 was not added" );
244+ }
245+
196246/* *
197247 * @brief Multiple messages in sequence: ST bootstrap, then I1, I3, I2, I4.
198248 */
@@ -287,7 +337,7 @@ static void test_incomplete_message() {
287337}
288338
289339int main () {
290- plan (70 );
340+ plan (83 );
291341
292342 test_bootstrap_single (); // 6 assertions
293343 test_bootstrap_range (); // 8 assertions
@@ -297,6 +347,9 @@ int main() {
297347 test_i3_range (); // 8 assertions
298348 test_i4_range_reuse_uuid (); // 7 assertions
299349 test_unknown_message_disconnects (); // 5 assertions
350+ test_malformed_bootstrap_disconnects (); // 4 assertions
351+ test_malformed_i3_disconnects (); // 5 assertions
352+ test_malformed_i4_disconnects (); // 4 assertions
300353 test_mixed_sequence (); // 14 assertions
301354 test_read_all_stops_on_unknown (); // 4 assertions
302355 test_empty_buffer (); // 3 assertions
0 commit comments