Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7bc4c22
CONC-786: Remove DEAD_STOREs
grooverdan Aug 20, 2025
d9e4e74
CONC-786: ma_default: env can be declared as const char *
grooverdan Aug 20, 2025
7747529
CONC-786: ma_dtoa: Balloc - resolve null ptr de-reference (OOM)
grooverdan Aug 20, 2025
606baea
CONC-786: mysql_stmt_send_long_data: return error on memory allocation
grooverdan Aug 20, 2025
99c6062
CONC-786: auth: send_client_reply_packet - return error if OOM
grooverdan Aug 20, 2025
a7dc811
CONC-786: tests: test return value
grooverdan Aug 20, 2025
10cdb70
CONC-786 tests: test_extended_init_values - OOM
grooverdan Aug 20, 2025
f7c5958
CONC-786 tests: check_mysql_rc and check_stmt_rc to cleanup
grooverdan Aug 20, 2025
662838a
CONC-786: ma_open under HAVE_REMOTEIO reads from uninitialized mysql …
grooverdan Aug 21, 2025
2c28fb4
CONC-786: async sock read without initialization
grooverdan Aug 21, 2025
dbc8422
CONC-786: dyncol: hdr.offset is read without initialization
grooverdan Aug 21, 2025
5c600e2
CONC-786: options_add_initcommand (via mysql_optionsv) had no OOM han…
grooverdan Aug 21, 2025
c48ea6d
CONC-786: OFFSET to use offsetof(stddef.h)
grooverdan Aug 21, 2025
23ce35b
CONC-786: ma_get_rset_field_lengths nullptr derefernce
grooverdan Aug 21, 2025
9d9b2e7
CONC-786: feof fail - rpl memory leak + client error
grooverdan Aug 21, 2025
318112a
CONC-786: rpl deadstore on processing
grooverdan Aug 21, 2025
f9b6917
CONC-786: mariadb_rpl_optionsv for MARIADB_RPL_FILENAME - OOM
grooverdan Aug 21, 2025
e3b7786
CONC-786: ma_rio_open failed to free memory
grooverdan Aug 21, 2025
c0a9e75
CONC-786: test_compress check setting option
grooverdan Aug 21, 2025
9f5c5a2
CONC-786: test_conc26 mysql_init memory allocation failure
grooverdan Aug 21, 2025
06caae2
CONC-786: test_conc118 check self kill
grooverdan Aug 21, 2025
a338d01
CONC-786: test_bind_address handle missing env
grooverdan Aug 21, 2025
0b85826
CONC-786: test_unix_socket_close free mysql on dummy socket failure
grooverdan Aug 21, 2025
1981779
CONC-786: test_mdev13100 free mysql correctly
grooverdan Aug 21, 2025
48f2a1e
CONC-786: test_expired_pw test DROP USER [IF EXISTS] result
grooverdan Aug 21, 2025
b1e9157
CONC-786: test_mdev35935 test mysql_select_db
grooverdan Aug 21, 2025
92265ce
CONC-786: execute_direct_example check create table result
grooverdan Aug 21, 2025
9550a27
CONC-786: conc_213 fail on stmt allocation failure
grooverdan Aug 21, 2025
88849b7
CONC-786: conc_212 check stmt close
grooverdan Aug 21, 2025
19ef753
CONC-786: mysql_init - free net.extensions on fail always
grooverdan Aug 22, 2025
5f31ab2
CONC-786: mariadb_reconnect mysql_init failure requires no mysql_close
grooverdan Aug 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ma_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ typedef long my_ptrdiff_t;
/* Size to make addressable obj. */
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
/* Offset of filed f in structure t */
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
#define OFFSET(t, f) (offsetof(t, f))
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))

Expand Down
1 change: 0 additions & 1 deletion libmariadb/ma_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ int bin2decimal(const char *from, decimal *to, int precision, int scale)
default: DBUG_ASSERT(0); x= 0;
}
*buf= (x ^ mask) * powers10[DIG_PER_DEC1 - frac0x];
buf++;
}
return error;
}
Expand Down
5 changes: 2 additions & 3 deletions libmariadb/ma_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ char **get_default_configuration_dirs()
#ifdef _WIN32
char dirname[FN_REFLEN];
#endif
char *env;
const char *env;

configuration_dirs= (char **)calloc(1, (MAX_CONFIG_DIRS + 1) * sizeof(char *));
if (!configuration_dirs)
Expand Down Expand Up @@ -299,7 +299,6 @@ static my_bool _mariadb_read_options_from_file(MYSQL *mysql,
}
*ptr=0;
set_option(mysql, key, optval);
key= optval= 0;
}
}
rc= 0;
Expand All @@ -323,7 +322,7 @@ my_bool _mariadb_read_options(MYSQL *mysql,
char filename[FN_REFLEN + 1];
unsigned int recursion_stop= 64;
#ifndef _WIN32
char *env;
const char *env;
#endif

if (recursion >= recursion_stop)
Expand Down
2 changes: 2 additions & 0 deletions libmariadb/ma_dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@ static Bigint *Balloc(int k, Stack_alloc *alloc)
else
rv= (Bigint*) malloc(len);

if (!rv)
return rv;
rv->k= k;
rv->maxwds= x;
}
Expand Down
3 changes: 1 addition & 2 deletions libmariadb/ma_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql)
/* check if plugin for remote io is available and try
* to open location */
{
MYSQL mysql;
if (rio_plugin ||(rio_plugin= (struct st_mysql_client_plugin_REMOTEIO *)
mysql_client_find_plugin(&mysql, NULL, MARIADB_CLIENT_REMOTEIO_PLUGIN)))
mysql_client_find_plugin(mysql, NULL, MARIADB_CLIENT_REMOTEIO_PLUGIN)))
return rio_plugin->methods->mopen(location, mode);
return NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion libmariadb/mariadb_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ my_connect_async(MARIADB_PVIO *pvio,
struct mysql_async_context *b= pvio->mysql->options.extension->async_context;
my_socket sock;

ma_pvio_get_handle(pvio, &sock);
if (ma_pvio_get_handle(pvio, &sock))
return -1;

/* Make the socket non-blocking. */
ma_pvio_blocking(pvio, 0, 0);
Expand Down
4 changes: 2 additions & 2 deletions libmariadb/mariadb_dyncol.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ init_read_hdr(DYN_HEADER *hdr, DYNAMIC_COLUMN *str)
if (read_fixed_header(hdr, str))
return ER_DYNCOL_FORMAT;
hdr->header= (uchar*)str->str + fmt_data[hdr->format].fixed_hdr;
hdr->offset= 0;
calc_param(&hdr->entry_size, &hdr->header_size,
fmt_data[hdr->format].fixed_hdr_entry, hdr->offset_size,
hdr->column_count);
Expand Down Expand Up @@ -2322,7 +2323,7 @@ dynamic_column_get_internal(DYNAMIC_COLUMN *str,
uint num_key, LEX_STRING *str_key)
{
DYN_HEADER header;
enum enum_dyncol_func_result rc= ER_DYNCOL_FORMAT;
enum enum_dyncol_func_result rc;
memset(&header, 0, sizeof(header));

if (str->length == 0)
Expand Down Expand Up @@ -3739,7 +3740,6 @@ mariadb_dyncol_check(DYNAMIC_COLUMN *str)
goto end;
}
}
prev_num= num;
prev_name= name;
prev_data_offset= data_offset;
prev_name_offset= name_offset;
Expand Down
40 changes: 26 additions & 14 deletions libmariadb/mariadb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,18 +774,31 @@ struct st_default_options mariadb_defaults[] =
#define OPT_SET_VALUE_INT(OPTS, KEY, VAL) \
(OPTS)->KEY= (VAL)

static void options_add_initcommand(struct st_mysql_options *options,
static my_bool options_add_initcommand(struct st_mysql_options *options,
const char *init_cmd)
{
char *insert= strdup(init_cmd);
if (!insert)
return TRUE;

if (!options->init_command)
{
options->init_command= (DYNAMIC_ARRAY*)malloc(sizeof(DYNAMIC_ARRAY));
if (!options->init_command)
{
free(insert);
return TRUE;
}
ma_init_dynamic_array(options->init_command, sizeof(char*), 5, 5);
}

if (ma_insert_dynamic(options->init_command, (gptr)&insert))
{
free(insert);
return TRUE;
}

return FALSE;
}
my_bool _mariadb_set_conf_option(MYSQL *mysql, const char *config_option, const char *config_value)
{
Expand Down Expand Up @@ -1061,7 +1074,7 @@ static my_bool ma_get_rset_field_lengths(MYSQL_ROW row, unsigned int field_count
unsigned long *lengths)
{
unsigned long *last_length= 0;
char *pos= 0;
const char *pos= 0;
MYSQL_ROW end= row + field_count + 1;
my_bool rc= 0;

Expand All @@ -1075,7 +1088,8 @@ static my_bool ma_get_rset_field_lengths(MYSQL_ROW row, unsigned int field_count
} else {
/* NULL_LENGTH (see also CONC-709) */
rc= 1;
*last_length= 0;
if (last_length)
*last_length= 0;
}
last_length= lengths++;
row++;
Expand Down Expand Up @@ -1138,11 +1152,6 @@ unpack_fields(const MYSQL *mysql,
field->flags= uint2korr(p);
p+= 2;
field->decimals= (uint) p[0];
p++;

/* filler */
p+= 2;

if (INTERNAL_NUM_FIELD(field))
field->flags|= NUM_FLAG;

Expand Down Expand Up @@ -1358,10 +1367,11 @@ mysql_init(MYSQL *mysql)
mysql->options.reconnect= 0;
return mysql;
error:
if (mysql->net.extension)
free(mysql->net.extension);
mysql->net.extension= 0;
if (mysql->free_me)
{
if (mysql->net.extension)
free(mysql->net.extension);
free(mysql);
}
return 0;
Expand Down Expand Up @@ -2106,11 +2116,8 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
{
/* extensions may have failed to allocate */
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
tmp_mysql.free_me= 0;
mysql_close(&tmp_mysql);
return(1);
}
tmp_mysql.free_me= 0;
tmp_mysql.options=mysql->options;
if (mysql->extension->conn_hdlr)
{
Expand Down Expand Up @@ -3484,7 +3491,11 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
}
break;
case MYSQL_INIT_COMMAND:
options_add_initcommand(&mysql->options, (char *)arg1);
if (options_add_initcommand(&mysql->options, (char *)arg1))
{
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
goto end;
}
break;
case MYSQL_READ_DEFAULT_FILE:
OPT_SET_VALUE_STR(&mysql->options, my_cnf_file, (char *)arg1);
Expand Down Expand Up @@ -3566,6 +3577,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
if(!(mysql->options.extension= (struct st_mysql_options_extension *)
calloc(1, sizeof(struct st_mysql_options_extension))))
{
my_context_destroy(&ctxt->async_context);
free(ctxt);
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
goto end;
Expand Down
Loading
Loading