@@ -376,12 +376,17 @@ bool GTID_Server_Data::read_next_gtid() {
376376 strncpy (rec_msg,data+pos,l);
377377 pos += l+1 ;
378378 rec_msg[l] = 0 ;
379+ bool invalid_msg = false ;
379380 if (rec_msg[0 ]==' I' ) {
380381 char *a = NULL ;
381382 int ul = 0 ;
382383 switch (rec_msg[1 ]) {
383384 case ' 1' : // single trxid with UUID
384385 a = strchr (rec_msg+3 ,' :' );
386+ if (a == NULL ) {
387+ invalid_msg = true ;
388+ break ;
389+ }
385390 ul = a-rec_msg-3 ;
386391 strncpy (uuid_server,rec_msg+3 ,ul);
387392 uuid_server[ul] = 0 ;
@@ -394,6 +399,10 @@ bool GTID_Server_Data::read_next_gtid() {
394399 break ;
395400 case ' 3' : // trxid range with UUID
396401 a = strchr (rec_msg+3 ,' :' );
402+ if (a == NULL ) {
403+ invalid_msg = true ;
404+ break ;
405+ }
397406 ul = a-rec_msg-3 ;
398407 strncpy (uuid_server,rec_msg+3 ,ul);
399408 uuid_server[ul] = 0 ;
@@ -405,10 +414,14 @@ bool GTID_Server_Data::read_next_gtid() {
405414 events_read++;
406415 break ;
407416 default :
408- proxy_warning (" GTID: unsupported message type 'I%c' from binlog reader on port %d for server %s:%d , disconnecting\n " ,
409- rec_msg[1 ], port, address, mysql_port);
410- active = false ;
411- return false ;
417+ invalid_msg = true ;
418+ }
419+
420+ if (invalid_msg) {
421+ proxy_warning (" GTID: unsupported message (%s) from binlog reader on port %d for server %s:%d, disconnecting\n " ,
422+ rec_msg, port, address, mysql_port);
423+ active = false ;
424+ return false ;
412425 }
413426 }
414427 }
0 commit comments