From b8e4effbcffd66dd8101d761bad5c7fc9d13b333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 18 Nov 2019 09:41:55 +1100 Subject: [PATCH] Fix buffer overflow for long GTID set #2395 --- lib/mysql_connection.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index ae43a7381..b18f0abaa 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -2201,6 +2201,9 @@ bool MySQL_Connection::get_gtid(char *buff, uint64_t *trx_id) { const char *data; size_t length; if (mysql_session_track_get_first(mysql, SESSION_TRACK_GTIDS, &data, &length) == 0) { + if (length >= (sizeof(gtid_uuid) - 1)) { + length = sizeof(gtid_uuid) - 1; + } if (memcmp(gtid_uuid,data,length)) { // copy to local buffer in MySQL_Connection memcpy(gtid_uuid,data,length);