Fix unsigned/signed conversion bug in event type during mysql_binlog_send().

Since event types can be >=128 and are read from a (possibly signed) char
pointer, we need to cast to unsigned char before extending to int, or we will
get an incorrect negative number. This was done in the main code path already,
but there is a rare case where we check for new events first without a lock
and then again with the lock. If the second check succeeds because a new event
turns up at just the right time, then we took a code path that was missing the
correct unsigned char cast, leading to incorrect handling of events for old
slave servers and possibly other grief.

(This was found from a sporadic failure in Buildbot of test case
rpl_mariadb_slave_capability).
This commit is contained in:
unknown 2013-04-25 13:16:35 +02:00
parent b54e5850d4
commit 203264ddc9

View File

@ -1026,7 +1026,8 @@ impossible position";
mysql_mutex_unlock(log_lock);
read_packet = 1;
p_coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
event_type=
(Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
break;
case LOG_READ_EOF: