Description:
In file group_replication_gcs_mysql_network_provider-t.cc:
TEST_F(MySQLNetworkProviderTest, CreateConnectionToSelfWithSSLTest) {
...
EXPECT_CALL(
*native_interface,
mysql_real_connect(testing::_, testing::_, testing::_, testing::_,
testing::_, testing::_, testing::_, testing::_))
.Times(1)
.WillRepeatedly(testing::DoAll(
[](MYSQL *mysql, const char *host, const char *user,
const char *passwd, const char *db, unsigned int port,
const char *unix_socket, unsigned long clientflag) {
(void)host;
(void)user;
(void)passwd;
(void)db;
(void)port;
(void)unix_socket;
(void)clientflag;
mysql->net.vio = (Vio *)malloc(sizeof(Vio));
SSL *fake_ssl_connection = (SSL *)malloc(sizeof(SSL *));
mysql->net.vio->ssl_arg = fake_ssl_connection;
},
testing::Return(fake_conn)));
...
}
Insufficient size ‘8’ for type ‘SSL’allocated in the line below:
SSL *fake_ssl_connection = (SSL *)malloc(sizeof(SSL *));
How to repeat:
Review the code in group_replication_gcs_mysql_network_provider-t.cc
Suggested fix:
Using malloc(sizeof(SSL)) instead:
SSL *fake_ssl_connection = (SSL *)malloc(sizeof(SSL));
Description: In file group_replication_gcs_mysql_network_provider-t.cc: TEST_F(MySQLNetworkProviderTest, CreateConnectionToSelfWithSSLTest) { ... EXPECT_CALL( *native_interface, mysql_real_connect(testing::_, testing::_, testing::_, testing::_, testing::_, testing::_, testing::_, testing::_)) .Times(1) .WillRepeatedly(testing::DoAll( [](MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag) { (void)host; (void)user; (void)passwd; (void)db; (void)port; (void)unix_socket; (void)clientflag; mysql->net.vio = (Vio *)malloc(sizeof(Vio)); SSL *fake_ssl_connection = (SSL *)malloc(sizeof(SSL *)); mysql->net.vio->ssl_arg = fake_ssl_connection; }, testing::Return(fake_conn))); ... } Insufficient size ‘8’ for type ‘SSL’allocated in the line below: SSL *fake_ssl_connection = (SSL *)malloc(sizeof(SSL *)); How to repeat: Review the code in group_replication_gcs_mysql_network_provider-t.cc Suggested fix: Using malloc(sizeof(SSL)) instead: SSL *fake_ssl_connection = (SSL *)malloc(sizeof(SSL));