Skip to content

Commit b923b80

Browse files
committed
Merge branch '10.6' into 10.7
2 parents cea5089 + c3a5cf2 commit b923b80

File tree

140 files changed

+4108
-717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+4108
-717
lines changed

CREDITS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ MariaDB Corporation https://www.mariadb.com (2013)
99
Microsoft https://microsoft.com/ (2017)
1010
ServiceNow https://servicenow.com (2019)
1111
SIT https://sit.org (2022)
12+
Tencent Cloud https://cloud.tencent.com (2017)
1213
Development Bank of Singapore https://dbs.com (2016)
1314
IBM https://www.ibm.com (2017)
1415
Automattic https://automattic.com (2019)

client/mysql.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,7 +3673,10 @@ print_table_data(MYSQL_RES *result)
36733673
{
36743674
print_field_types(result);
36753675
if (!mysql_num_rows(result))
3676+
{
3677+
my_afree((uchar*) num_flag);
36763678
return;
3679+
}
36773680
mysql_field_seek(result,0);
36783681
}
36793682
separator.copy("+",1,charset_info);

client/mysql_plugin.c

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,14 @@ static int file_exists(char * filename)
569569
@retval int error = 1, success = 0
570570
*/
571571

572-
static int search_dir(const char * base_path, const char *tool_name,
572+
static int search_dir(const char *base_path, const char *tool_name,
573573
const char *subdir, char *tool_path)
574574
{
575575
char new_path[FN_REFLEN];
576576
char source_path[FN_REFLEN];
577577

578-
strcpy(source_path, base_path);
579-
strcat(source_path, subdir);
578+
safe_strcpy(source_path, sizeof(source_path), base_path);
579+
safe_strcat(source_path, sizeof(source_path), subdir);
580580
fn_format(new_path, tool_name, source_path, "", MY_UNPACK_FILENAME);
581581
if (file_exists(new_path))
582582
{
@@ -632,7 +632,7 @@ static int load_plugin_data(char *plugin_name, char *config_file)
632632
FILE *file_ptr;
633633
char path[FN_REFLEN];
634634
char line[1024];
635-
char *reason= 0;
635+
const char *reason= 0;
636636
char *res;
637637
int i= -1;
638638

@@ -643,14 +643,14 @@ static int load_plugin_data(char *plugin_name, char *config_file)
643643
}
644644
if (!file_exists(opt_plugin_ini))
645645
{
646-
reason= (char *)"File does not exist.";
646+
reason= "File does not exist.";
647647
goto error;
648648
}
649649

650650
file_ptr= fopen(opt_plugin_ini, "r");
651651
if (file_ptr == NULL)
652652
{
653-
reason= (char *)"Cannot open file.";
653+
reason= "Cannot open file.";
654654
goto error;
655655
}
656656

@@ -660,17 +660,20 @@ static int load_plugin_data(char *plugin_name, char *config_file)
660660
/* Read plugin components */
661661
while (i < 16)
662662
{
663+
size_t line_len;
664+
663665
res= fgets(line, sizeof(line), file_ptr);
666+
line_len= strlen(line);
667+
664668
/* strip /n */
665-
if (line[strlen(line)-1] == '\n')
666-
{
667-
line[strlen(line)-1]= '\0';
668-
}
669+
if (line[line_len - 1] == '\n')
670+
line[line_len - 1]= '\0';
671+
669672
if (res == NULL)
670673
{
671674
if (i < 1)
672675
{
673-
reason= (char *)"Bad format in plugin configuration file.";
676+
reason= "Bad format in plugin configuration file.";
674677
fclose(file_ptr);
675678
goto error;
676679
}
@@ -683,14 +686,19 @@ static int load_plugin_data(char *plugin_name, char *config_file)
683686
if (i == -1) /* if first pass, read this line as so_name */
684687
{
685688
/* Add proper file extension for soname */
686-
strcat(line, FN_SOEXT);
689+
if (safe_strcpy(line + line_len - 1, sizeof(line), FN_SOEXT))
690+
{
691+
reason= "Plugin name too long.";
692+
fclose(file_ptr);
693+
goto error;
694+
}
687695
/* save so_name */
688696
plugin_data.so_name= my_strdup(PSI_NOT_INSTRUMENTED, line, MYF(MY_WME|MY_ZEROFILL));
689697
i++;
690698
}
691699
else
692700
{
693-
if (strlen(line) > 0)
701+
if (line_len > 0)
694702
{
695703
plugin_data.components[i]= my_strdup(PSI_NOT_INSTRUMENTED, line, MYF(MY_WME));
696704
i++;
@@ -779,14 +787,13 @@ static int check_options(int argc, char **argv, char *operation)
779787
/* read the plugin config file and check for match against argument */
780788
else
781789
{
782-
if (strlen(argv[i]) + 4 + 1 > FN_REFLEN)
790+
if (safe_strcpy(plugin_name, sizeof(plugin_name), argv[i]) ||
791+
safe_strcpy(config_file, sizeof(config_file), argv[i]) ||
792+
safe_strcat(config_file, sizeof(config_file), ".ini"))
783793
{
784794
fprintf(stderr, "ERROR: argument is too long.\n");
785795
return 1;
786796
}
787-
strcpy(plugin_name, argv[i]);
788-
strcpy(config_file, argv[i]);
789-
strcat(config_file, ".ini");
790797
}
791798
}
792799

@@ -855,35 +862,30 @@ static int check_options(int argc, char **argv, char *operation)
855862
static int process_options(int argc, char *argv[], char *operation)
856863
{
857864
int error= 0;
858-
int i= 0;
859865

860866
/* Parse and execute command-line options */
861867
if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
862-
goto exit;
868+
return error;
863869

864870
/* If the print defaults option used, exit. */
865871
if (opt_print_defaults)
866-
{
867-
error= -1;
868-
goto exit;
869-
}
872+
return -1;
870873

871874
/* Add a trailing directory separator if not present */
872875
if (opt_basedir)
873876
{
874-
i= (int)strlength(opt_basedir);
875-
if (opt_basedir[i-1] != FN_LIBCHAR || opt_basedir[i-1] != FN_LIBCHAR2)
877+
size_t basedir_len= strlength(opt_basedir);
878+
if (opt_basedir[basedir_len - 1] != FN_LIBCHAR ||
879+
opt_basedir[basedir_len - 1] != FN_LIBCHAR2)
876880
{
877881
char buff[FN_REFLEN];
878-
memset(buff, 0, sizeof(buff));
879-
880-
strncpy(buff, opt_basedir, sizeof(buff) - 1);
881-
#ifdef _WIN32
882-
strncat(buff, "/", sizeof(buff) - strlen(buff) - 1);
883-
#else
884-
strncat(buff, FN_DIRSEP, sizeof(buff) - strlen(buff) - 1);
885-
#endif
886-
buff[sizeof(buff) - 1]= 0;
882+
if (basedir_len + 2 > FN_REFLEN)
883+
return -1;
884+
885+
memcpy(buff, opt_basedir, basedir_len);
886+
buff[basedir_len]= '/';
887+
buff[basedir_len + 1]= '\0';
888+
887889
my_free(opt_basedir);
888890
opt_basedir= my_strdup(PSI_NOT_INSTRUMENTED, buff, MYF(MY_FAE));
889891
}
@@ -895,22 +897,17 @@ static int process_options(int argc, char *argv[], char *operation)
895897
generated when the defaults were read from the file, exit.
896898
*/
897899
if (!opt_no_defaults && ((error= get_default_values())))
898-
{
899-
error= -1;
900-
goto exit;
901-
}
900+
return -1;
902901

903902
/*
904903
Check to ensure required options are present and validate the operation.
905904
Note: this method also validates the plugin specified by attempting to
906905
read a configuration file named <plugin_name>.ini from the --plugin-dir
907906
or --plugin-ini location if the --plugin-ini option presented.
908907
*/
909-
strcpy(operation, "");
910-
if ((error = check_options(argc, argv, operation)))
911-
{
912-
goto exit;
913-
}
908+
operation[0]= '\0';
909+
if ((error= check_options(argc, argv, operation)))
910+
return error;
914911

915912
if (opt_verbose)
916913
{
@@ -922,8 +919,7 @@ static int process_options(int argc, char *argv[], char *operation)
922919
printf("# lc_messages_dir = %s\n", opt_lc_messages_dir);
923920
}
924921

925-
exit:
926-
return error;
922+
return 0;
927923
}
928924

929925

client/mysqldump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,7 @@ static uint dump_events_for_db(char *db)
25942594
if (mysql_query_with_error_report(mysql, &event_list_res, "show events"))
25952595
DBUG_RETURN(0);
25962596

2597-
strcpy(delimiter, ";");
2597+
safe_strcpy(delimiter, sizeof(delimiter), ";");
25982598
if (mysql_num_rows(event_list_res) > 0)
25992599
{
26002600
if (opt_xml)

client/mysqltest.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6181,7 +6181,9 @@ int do_done(struct st_command *command)
61816181
if (*cur_block->delim)
61826182
{
61836183
/* Restore "old" delimiter after false if block */
6184-
strcpy (delimiter, cur_block->delim);
6184+
if (safe_strcpy(delimiter, sizeof(delimiter), cur_block->delim))
6185+
die("Delimiter too long, truncated");
6186+
61856187
delimiter_length= strlen(delimiter);
61866188
}
61876189
/* Pop block from stack, goto next line */
@@ -6436,10 +6438,12 @@ void do_block(enum block_cmd cmd, struct st_command* command)
64366438
if (cur_block->ok)
64376439
{
64386440
cur_block->delim[0]= '\0';
6439-
} else
6441+
}
6442+
else
64406443
{
64416444
/* Remember "old" delimiter if entering a false if block */
6442-
strcpy (cur_block->delim, delimiter);
6445+
if (safe_strcpy(cur_block->delim, sizeof(cur_block->delim), delimiter))
6446+
die("Delimiter too long, truncated");
64436447
}
64446448

64456449
DBUG_PRINT("info", ("OK: %d", cur_block->ok));
@@ -11845,9 +11849,8 @@ static int setenv(const char *name, const char *value, int overwrite)
1184511849
char *envvar= (char *)malloc(buflen);
1184611850
if(!envvar)
1184711851
return ENOMEM;
11848-
strcpy(envvar, name);
11849-
strcat(envvar, "=");
11850-
strcat(envvar, value);
11852+
11853+
snprintf(envvar, buflen, "%s=%s", name, value);
1185111854
putenv(envvar);
1185211855
return 0;
1185311856
}

cmake/install_macros.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ IF(WIN32)
179179
OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF)
180180
MARK_AS_ADVANCED(SIGNCODE)
181181
IF(SIGNCODE)
182-
SET(SIGNTOOL_PARAMETERS
183-
/a /t http://timestamp.globalsign.com/?signature=sha2
182+
SET(SIGNTOOL_PARAMETERS
183+
/a /fd SHA256 /t http://timestamp.globalsign.com/?signature=sha2
184184
CACHE STRING "parameters for signtool (list)")
185185
IF(NOT SIGNTOOL_EXECUTABLE)
186186
FILE(GLOB path_list

dbug/dbug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static int DbugParse(CODE_STATE *cs, const char *control)
511511
stack->delay= stack->next->delay;
512512
stack->maxdepth= stack->next->maxdepth;
513513
stack->sub_level= stack->next->sub_level;
514-
strcpy(stack->name, stack->next->name);
514+
safe_strcpy(stack->name, sizeof(stack->name), stack->next->name);
515515
stack->out_file= stack->next->out_file;
516516
stack->out_file->used++;
517517
if (stack->next == &init_settings)

extra/innochecksum.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,19 +772,15 @@ parse_page(
772772
{
773773
unsigned long long id;
774774
uint16_t undo_page_type;
775-
char str[20]={'\0'};
775+
const char *str;
776776
ulint n_recs;
777777
uint32_t page_no, left_page_no, right_page_no;
778778
ulint data_bytes;
779779
bool is_leaf;
780780
ulint size_range_id;
781781

782782
/* Check whether page is doublewrite buffer. */
783-
if(skip_page) {
784-
strcpy(str, "Double_write_buffer");
785-
} else {
786-
strcpy(str, "-");
787-
}
783+
str = skip_page ? "Double_write_buffer" : "-";
788784

789785
switch (fil_page_get_type(page)) {
790786

extra/mariabackup/backup_copy.cc

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA
5858
#include "backup_debug.h"
5959
#include "backup_mysql.h"
6060
#include <btr0btr.h>
61+
#ifdef _WIN32
62+
#include <direct.h> /* rmdir */
63+
#endif
6164

6265
#ifdef _WIN32
6366
#include <aclapi.h>
@@ -1562,7 +1565,49 @@ bool backup_finish()
15621565
return(true);
15631566
}
15641567

1565-
bool
1568+
1569+
/*
1570+
Drop all empty database directories in the base backup
1571+
that do not exists in the icremental backup.
1572+
1573+
This effectively re-plays all DROP DATABASE statements happened
1574+
in between base backup and incremental backup creation time.
1575+
1576+
Note, only checking if base_dir/db/ is empty is not enough,
1577+
because inc_dir/db/db.opt might have been dropped for some reasons,
1578+
which may also result into empty base_dir/db/.
1579+
1580+
Only the fact that at the same time:
1581+
- base_dir/db/ exists
1582+
- inc_dir/db/ does not exist
1583+
means that DROP DATABASE happened.
1584+
*/
1585+
static void
1586+
ibx_incremental_drop_databases(const char *base_dir,
1587+
const char *inc_dir)
1588+
{
1589+
datadir_node_t node;
1590+
datadir_node_init(&node);
1591+
datadir_iter_t *it = datadir_iter_new(base_dir);
1592+
1593+
while (datadir_iter_next(it, &node)) {
1594+
if (node.is_empty_dir) {
1595+
char path[FN_REFLEN];
1596+
snprintf(path, sizeof(path), "%s/%s",
1597+
inc_dir, node.filepath_rel);
1598+
if (!directory_exists(path, false)) {
1599+
msg("Removing %s", node.filepath);
1600+
rmdir(node.filepath);
1601+
}
1602+
}
1603+
1604+
}
1605+
datadir_iter_free(it);
1606+
datadir_node_free(&node);
1607+
}
1608+
1609+
1610+
static bool
15661611
ibx_copy_incremental_over_full()
15671612
{
15681613
const char *ext_list[] = {"frm", "isl", "MYD", "MYI", "MAD", "MAI",
@@ -1645,6 +1690,8 @@ ibx_copy_incremental_over_full()
16451690
}
16461691
copy_or_move_dir(path, ROCKSDB_BACKUP_DIR, true, true);
16471692
}
1693+
ibx_incremental_drop_databases(xtrabackup_target_dir,
1694+
xtrabackup_incremental_dir);
16481695
}
16491696

16501697

extra/mariabackup/xbcloud.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,8 +1676,11 @@ container_list_add_object(container_list *list, const char *name,
16761676
list->object_count += object_count_step;
16771677
}
16781678
assert(list->idx <= list->object_count);
1679-
strcpy(list->objects[list->idx].name, name);
1680-
strcpy(list->objects[list->idx].hash, hash);
1679+
safe_strcpy(list->objects[list->idx].name,
1680+
sizeof(list->objects[list->idx].name), name);
1681+
safe_strcpy(list->objects[list->idx].hash,
1682+
sizeof(list->objects[list->idx].hash), hash);
1683+
16811684
list->objects[list->idx].bytes = bytes;
16821685
++list->idx;
16831686
}

0 commit comments

Comments
 (0)