summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2013-04-25 13:16:35 +0200
committerunknown <knielsen@knielsen-hq.org>2013-04-25 13:16:35 +0200
commit203264ddc9c399fa4a86b589ae638eccfb66e9ed (patch)
treef15e3d49ce7b5cbf83190ad9269765961bfc4b51 /sql/sql_repl.cc
parentb54e5850d425f73a51f3210981cd609b604e9698 (diff)
downloadmariadb-git-203264ddc9c399fa4a86b589ae638eccfb66e9ed.tar.gz
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).
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index b8a12b1ea8a..be9717cdc65 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -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: