summaryrefslogtreecommitdiff
path: root/tests/mysql_client_test.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-04 19:28:43 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-04 19:28:43 +0300
commitf3bd2780632288bec8e8462404df0fea356afd7d (patch)
treedf53e8548fe46a8d454b5a5740a4dc179fa66ccf /tests/mysql_client_test.c
parent32839c4df237bd64807e4e92a1fabe14eb6df783 (diff)
downloadmariadb-git-f3bd2780632288bec8e8462404df0fea356afd7d.tar.gz
MDEV-22083/MDEV-26758: Fix uninitialized memory in mysql_client_test
The test was passing some uninitialized data to libmariadb. Mostly, the MemorySanitizer wrapper of send() detected that some bytes were uninitialized. The test_mdev19838() is for now disabled under MemorySanitizer, to be fixed in MDEV-26761.
Diffstat (limited to 'tests/mysql_client_test.c')
-rw-r--r--tests/mysql_client_test.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 87e1304387b..3cc96193e4a 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2014, Oracle and/or its affiliates.
- Copyright (c) 2008, 2020, MariaDB
+ Copyright (c) 2008, 2021, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,6 +40,8 @@
#include <arpa/inet.h>
#endif
+#include "my_valgrind.h"
+
static const my_bool my_true= 1;
@@ -672,6 +674,11 @@ static void test_wl4435()
/* Init PS-parameters. */
+ memset(str_data, 0, sizeof str_data);
+ memset(dbl_data, 0, sizeof dbl_data);
+ memset(dec_data, 0, sizeof dec_data);
+ memset(int_data, 0, sizeof int_data);
+
bzero((char *) ps_params, sizeof (ps_params));
/* - v0 -- INT */
@@ -1072,7 +1079,7 @@ static void test_wl4435_2()
MYSQL_RES *rs_metadata; \
MYSQL_FIELD *fields; \
c_type pspv c_type_ext; \
- my_bool psp_null; \
+ my_bool psp_null= FALSE; \
\
bzero(&pspv, sizeof (pspv)); \
\
@@ -1133,6 +1140,7 @@ static void test_wl4435_3()
{
char tmp[255];
+ memset(tmp, 0, sizeof tmp);
puts("");
/*
@@ -1631,6 +1639,7 @@ static void test_double_compare()
my_bind[2].buffer= (void *)&double_data;
tiny_data= 1;
+ memset(real_data, 0, sizeof real_data);
strmov(real_data, "10.2");
double_data= 34.5;
rc= mysql_stmt_bind_param(stmt, my_bind);
@@ -7419,6 +7428,7 @@ static void test_decimal_bug()
rc= mysql_stmt_bind_param(stmt, my_bind);
check_execute(stmt, rc);
+ memset(data, 0, sizeof data);
strmov(data, "8.0");
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
@@ -11571,6 +11581,7 @@ static void test_view_insert_fields()
my_bind[i].is_null= 0;
my_bind[i].buffer= (char *)&parm[i];
+ memset(parm[i], 0, sizeof parm[i]);
strmov(parm[i], "1");
my_bind[i].buffer_length= 2;
my_bind[i].length= &l[i];
@@ -13168,6 +13179,7 @@ static void test_bug8330()
check_execute(stmt[i], rc);
my_bind[i].buffer_type= MYSQL_TYPE_LONG;
+ lval[i]= 0;
my_bind[i].buffer= (void*) &lval[i];
my_bind[i].is_null= 0;
mysql_stmt_bind_param(stmt[i], &my_bind[i]);
@@ -15904,6 +15916,7 @@ static void test_bug20152()
my_bind[0].buffer_type= MYSQL_TYPE_DATE;
my_bind[0].buffer= (void*)&tm;
+ memset(&tm, 0, sizeof tm);
tm.year = 2006;
tm.month = 6;
tm.day = 18;
@@ -18939,6 +18952,7 @@ static void test_bug49972()
in_param_bind.buffer_type= MYSQL_TYPE_LONG;
in_param_bind.buffer= (char *) &int_data;
+ int_data= 0;
in_param_bind.length= 0;
in_param_bind.is_null= 0;
@@ -19457,6 +19471,7 @@ static void test_ps_sp_out_params()
DIE_UNLESS(mysql_stmt_param_count(stmt) == 1);
memset(bind, 0, sizeof(MYSQL_BIND));
+ memset(buffer, 0, sizeof buffer);
bind[0].buffer= buffer;
bind[0].buffer_length= sizeof(buffer);
bind[0].buffer_type= MYSQL_TYPE_STRING;
@@ -20132,6 +20147,7 @@ static void test_mdev14454_internal(const char *init,
DIE_UNLESS(rc == 0);
DIE_UNLESS(mysql_stmt_param_count(stmt) == 1);
+ memset(&bind, 0, sizeof bind);
bind.buffer_type= MYSQL_TYPE_NULL;
rc= mysql_stmt_bind_param(stmt, &bind);
DIE_UNLESS(rc == 0);
@@ -20140,7 +20156,6 @@ static void test_mdev14454_internal(const char *init,
DIE_UNLESS(rc == 0);
memset(res, 0, sizeof(res));
- memset(&bind, 0, sizeof(bind));
bind.buffer_type= MYSQL_TYPE_STRING;
bind.buffer_length= sizeof(res);
bind.buffer= res;
@@ -20753,6 +20768,7 @@ static void test_ps_params_in_ctes()
int_data[0]=2;
+ memset(ps_params, 0, sizeof ps_params);
ps_params[0].buffer_type= MYSQL_TYPE_LONG;
ps_params[0].buffer= (char *) &int_data[0];
ps_params[0].length= 0;
@@ -21178,7 +21194,10 @@ static void test_explain_meta()
}
-#ifndef EMBEDDED_LIBRARY
+#if __has_feature(memory_sanitizer)
+/* FIXME: MDEV-26761: main.mysql_client_test fails with MemorySanitizer */
+#elif defined EMBEDDED_LIBRARY
+#else
#define MDEV19838_MAX_PARAM_COUNT 32
#define MDEV19838_FIELDS_COUNT 17
static void test_mdev19838()
@@ -21670,7 +21689,10 @@ static struct my_tests_st my_tests[]= {
#endif
{ "test_ps_params_in_ctes", test_ps_params_in_ctes },
{ "test_explain_meta", test_explain_meta },
-#ifndef EMBEDDED_LIBRARY
+#if __has_feature(memory_sanitizer)
+/* FIXME: MDEV-26761: main.mysql_client_test fails with MemorySanitizer */
+#elif defined EMBEDDED_LIBRARY
+#else
{ "test_mdev19838", test_mdev19838 },
#endif
{ "test_mdev18408", test_mdev18408 },