Skip to content

Commit 59af68e

Browse files
committed
MDEV-37809 : MSAN use-of-uninitialized-value in wsrep_xid_print
Uninitialized value was created by an allocation of 'xid' in the stack frame. Fixed by explicit initialization of xid.
1 parent 1bdaabc commit 59af68e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sql/wsrep_xid.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
#define WSREP_XID_RPL_GTID_OFFSET (WSREP_XID_SEQNO_OFFSET + sizeof(wsrep_seqno_t))
4343
#define WSREP_XID_GTRID_LEN_V_3 (WSREP_XID_RPL_GTID_OFFSET + sizeof(wsrep_server_gtid_t))
4444

45+
void inline wsrep_xid_init(XID *xid)
46+
{
47+
xid->null();
48+
xid->gtrid_length= 0;
49+
xid->bqual_length= 0;
50+
memset(xid->data, 0, sizeof(xid->data));
51+
}
52+
4553
void wsrep_xid_init(XID* xid, const wsrep::gtid& wsgtid, const wsrep_server_gtid_t& gtid)
4654
{
4755
xid->formatID= 1;
@@ -161,8 +169,6 @@ bool wsrep_get_SE_checkpoint(XID& xid)
161169

162170
static bool wsrep_get_SE_checkpoint_common(XID& xid)
163171
{
164-
xid.null();
165-
166172
if (wsrep_get_SE_checkpoint(xid))
167173
{
168174
return FALSE;
@@ -186,6 +192,7 @@ template<>
186192
wsrep::gtid wsrep_get_SE_checkpoint()
187193
{
188194
XID xid;
195+
wsrep_xid_init(&xid);
189196

190197
if (!wsrep_get_SE_checkpoint_common(xid))
191198
{
@@ -199,6 +206,7 @@ template<>
199206
wsrep_server_gtid_t wsrep_get_SE_checkpoint()
200207
{
201208
XID xid;
209+
wsrep_xid_init(&xid);
202210
wsrep_server_gtid_t gtid= {0,0,0};
203211

204212
if (!wsrep_get_SE_checkpoint_common(xid))

0 commit comments

Comments
 (0)