Skip to content

Commit 9cb70f0

Browse files
committed
Merge branch '11.4' into 11.8
2 parents 04e0901 + 7598e4e commit 9cb70f0

571 files changed

Lines changed: 9983 additions & 9016 deletions

File tree

Some content is hidden

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

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ MariaDB Server has a vibrant community contributing in a wide range of areas. Th
88
- [maria-developers mailing list](https://lists.mariadb.org/postorius/lists/developers.lists.mariadb.org/)
99
- [maria-discuss mailing list](https://lists.mariadb.org/postorius/lists/discuss.lists.mariadb.org/)
1010
- [maria-docs mailing list](https://lists.mariadb.org/postorius/lists/docs.lists.mariadb.org/)
11-
- The MariaDB Foundation and MariaDB Corporation have a presence on Reddit, Twitter and Facebook. See the [social media page](https://mariadb.com/docs/general-resources/community/joining-the-community).
11+
- The MariaDB Foundation and MariaDB Corporation have a presence on Reddit, Twitter and Facebook. See the [social media page](https://mariadb.com/docs/general-resources/community/joining-the-community).
1212

1313
### Help document MariaDB
14-
----
15-
- Contribute towards [documenting MariaDB Server](https://mariadb.com/docs/general-resources/about/readme/contributing-documentation) and its ecosystem by adding new content or improving existing content.
16-
- [Translate](https://mariadb.com/docs/general-resources/about/readme/contributing-documentation) existing documentation.
14+
---
15+
- Contribute towards [documenting MariaDB Server](https://mariadb.com/docs/general-resources/about/readme/contributing-documentation) and its ecosystem by adding new content or improving existing content.
16+
- [Translate](https://mariadb.com/docs/general-resources/about/readme/contributing-documentation) existing documentation.
1717

1818
### Help develop MariaDB
19-
-----
19+
---
2020
- Fix bugs or develop new features
2121
- Review code contributions
2222
- Test bug fixes and features
@@ -34,10 +34,10 @@ You’re very welcome to support MariaDB Server as an individual, or talk your c
3434
---
3535
- Attend an event
3636
- [Events and Conferences page](https://mariadb.org/events/)
37-
- [mariadb.meetup.com](http://mariadb.meetup.com/)
37+
- [mariadb.meetup.com](https://mariadb.meetup.com/)
3838

3939
### Live Q&A for beginner contributors
40-
----
40+
---
4141
MariaDB has a dedicated time each week when we answer new contributor questions live on Zulip.
4242
From 8:00 to 10:00 UTC on Mondays, and 10:00 to 12:00 UTC on Thursdays, anyone can ask any questions they’d like,
4343
and a live developer will be available to assist.

client/mysql.cc

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,9 @@ static void print_tab_data(MYSQL_RES *result);
11661166
static void print_table_data_vertically(MYSQL_RES *result);
11671167
static void print_warnings(void);
11681168
static void print_last_query_cost(void);
1169-
static void end_timer(ulonglong start_time, char *buff);
1170-
static void nice_time(double sec,char *buff,bool part_second);
1169+
static void end_timer(ulonglong start_time, char *buff, size_t buff_size);
1170+
static void nice_time(double sec, char *buff, size_t buff_size,
1171+
bool part_second);
11711172
extern "C" sig_handler mysql_end(int sig) __attribute__ ((noreturn));
11721173
extern "C" sig_handler handle_sigint(int sig);
11731174
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
@@ -1425,18 +1426,20 @@ int main(int argc,char *argv[])
14251426
histfile=my_strdup(PSI_NOT_INSTRUMENTED, histfile, MYF(MY_WME));
14261427
else if ((home= getenv("HOME")))
14271428
{
1429+
size_t histfile_size=
1430+
strlen(home) + strlen("/.mysql_history") + 2;
14281431
histfile=(char*) my_malloc(PSI_NOT_INSTRUMENTED,
1429-
strlen(home) + strlen("/.mariadb_history")+2, MYF(MY_WME));
1432+
histfile_size, MYF(MY_WME));
14301433
if (histfile)
14311434
{
1432-
sprintf(histfile,"%s/.mariadb_history", home);
1435+
snprintf(histfile, histfile_size, "%s/.mariadb_history", home);
14331436
if (my_access(histfile, F_OK))
14341437
{
14351438
/* no .mariadb_history, look for historical name and use if present */
1436-
sprintf(histfile,"%s/.mysql_history", home);
1439+
snprintf(histfile, histfile_size, "%s/.mysql_history", home);
14371440
/* and go back to original if not found */
14381441
if (my_access(histfile, F_OK))
1439-
sprintf(histfile,"%s/.mariadb_history", home);
1442+
snprintf(histfile, histfile_size, "%s/.mariadb_history", home);
14401443
}
14411444
char link_name[FN_REFLEN];
14421445
if (my_readlink(link_name, histfile, 0) == 0 &&
@@ -3673,7 +3676,7 @@ static int com_go(String *buffer, char *)
36733676

36743677
report_progress_end();
36753678
if (verbose >= 3 || !opt_silent)
3676-
end_timer(timer, time_buff);
3679+
end_timer(timer, time_buff, sizeof(time_buff));
36773680
else
36783681
time_buff[0]= '\0';
36793682

@@ -3709,9 +3712,9 @@ static int com_go(String *buffer, char *)
37093712
print_tab_data(result);
37103713
else
37113714
print_table_data(result);
3712-
snprintf(buff, sizeof(buff), "%ld %s in set",
3713-
(long) mysql_num_rows(result),
3714-
(long) mysql_num_rows(result) == 1 ? "row" : "rows");
3715+
snprintf(buff, sizeof(buff), "%llu %s in set",
3716+
(unsigned long long) mysql_num_rows(result),
3717+
mysql_num_rows(result) == 1 ? "row" : "rows");
37153718
end_pager();
37163719
if (mysql_errno(&mysql))
37173720
{
@@ -3725,7 +3728,7 @@ static int com_go(String *buffer, char *)
37253728
strmov(buff,"Query OK");
37263729
else
37273730
snprintf(buff, sizeof(buff), "Query OK, %llu %s affected",
3728-
mysql_affected_rows(&mysql),
3731+
(unsigned long long) mysql_affected_rows(&mysql),
37293732
mysql_affected_rows(&mysql) == 1 ? "row" : "rows");
37303733

37313734
pos=strend(buff);
@@ -3904,7 +3907,7 @@ static char *fieldflags2str(uint f) {
39043907
ff2s_check_flag(ON_UPDATE_NOW);
39053908
#undef ff2s_check_flag
39063909
if (f)
3907-
snprintf(s, sizeof(buf), " unknows=0x%04x", f);
3910+
snprintf(s, sizeof(buf) - (size_t)(s - buf), " unknown=0x%04x", f);
39083911
return buf;
39093912
}
39103913

@@ -4655,8 +4658,10 @@ com_edit(String *buffer,char *)
46554658
strxmov(buff,editor," ",filename,NullS);
46564659
if ((error= system(buff)))
46574660
{
4658-
char errmsg[100];
4659-
snprintf(errmsg, sizeof(errmsg), "Command '%.40s' failed", buff);
4661+
#define EDITOR_FAIL_MSG "Command '%.40s' failed"
4662+
char errmsg[sizeof(EDITOR_FAIL_MSG) - 1 + 40];
4663+
snprintf(errmsg, sizeof(errmsg), EDITOR_FAIL_MSG, buff);
4664+
#undef EDITOR_FAIL_MSG
46604665
put_info(errmsg, INFO_ERROR, 0, NullS);
46614666
goto err;
46624667
}
@@ -5352,7 +5357,7 @@ static int com_status(String *, char *)
53525357
tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status_str), status_str);
53535358
if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec)))
53545359
{
5355-
nice_time((double) sec,buff,0);
5360+
nice_time((double) sec,buff, sizeof(buff),0);
53565361
tee_puts(buff, stdout); /* print nice time */
53575362
while (*status_str == ' ')
53585363
status_str++; /* to next info */
@@ -5571,8 +5576,10 @@ void tee_putc(int c, FILE *file)
55715576
55725577
len("4294967296 days, 23 hours, 59 minutes, 60.000 seconds") -> 53
55735578
*/
5574-
static void nice_time(double sec, char *buff, bool part_second)
5579+
static void nice_time(double sec, char *buff, size_t buff_size,
5580+
bool part_second)
55755581
{
5582+
char *buff_end= buff + buff_size;
55765583
ulong tmp;
55775584
if (sec >= 3600.0*24)
55785585
{
@@ -5596,21 +5603,23 @@ static void nice_time(double sec, char *buff, bool part_second)
55965603
buff=strmov(buff," min ");
55975604
}
55985605
if (part_second)
5599-
sprintf(buff,"%.3f sec",sec);
5606+
snprintf(buff, buff_end - buff, "%.3f sec", sec);
56005607
else
5601-
sprintf(buff,"%d sec",(int) sec);
5608+
snprintf(buff, buff_end - buff, "%d sec", (int) sec);
56025609
}
56035610

56045611

5605-
static void end_timer(ulonglong start_time, char *buff)
5612+
static void end_timer(ulonglong start_time, char *buff, size_t buff_size)
56065613
{
56075614
double sec;
56085615

5616+
if (buff_size < 4)
5617+
return;
56095618
buff[0]=' ';
56105619
buff[1]='(';
56115620
sec= (microsecond_interval_timer() - start_time) / (double) (1000 * 1000);
5612-
nice_time(sec, buff + 2, 1);
5613-
strmov(strend(buff),")");
5621+
nice_time(sec, buff + 2, buff_size - 2, 1);
5622+
snprintf(strend(buff), buff_size - (strend(buff) - buff), ")");
56145623
}
56155624

56165625
static const char *construct_prompt()

client/mysql_upgrade.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)
511511
static void find_tool(char *tool_executable_name, const char *tool_name,
512512
const char *self_name)
513513
{
514-
char *last_fn_libchar;
514+
const char *last_fn_libchar;
515515
DYNAMIC_STRING ds_tmp;
516516
DBUG_ENTER("find_tool");
517517
DBUG_PRINT("enter", ("progname: %s", my_progname));

client/mysqladmin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
725725

726726
if (opt_shutdown_wait_for_slaves)
727727
{
728-
sprintf(buff, "SHUTDOWN WAIT FOR ALL SLAVES");
728+
snprintf(buff, sizeof(buff), "SHUTDOWN WAIT FOR ALL SLAVES");
729729
if (mysql_query(mysql, buff))
730730
{
731731
my_printf_error(0, "%s failed; error: '%-.200s'",

client/mysqlbinlog.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,14 @@ class Load_log_processor
313313
@retval -1 Error (can't find new filename).
314314
@retval >=0 Found file.
315315
*/
316-
File create_unique_file(char *filename, char *file_name_end)
316+
File create_unique_file(char *filename, char *file_name_end,
317+
size_t buf_remaining)
317318
{
318319
File res;
319320
/* If we have to try more than 1000 times, something is seriously wrong */
320321
for (uint version= 0; version<1000; version++)
321322
{
322-
sprintf(file_name_end,"-%x",version);
323+
snprintf(file_name_end, buf_remaining, "-%x", version);
323324
if ((res= my_create(filename,0,
324325
O_CREAT|O_EXCL|O_BINARY|O_WRONLY,MYF(0)))!=-1)
325326
return res;
@@ -445,7 +446,8 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
445446
//so the rest of fname has size full_len - target_dir_name_len
446447
ptr+= snprintf(ptr, full_len - target_dir_name_len, "-%x", file_id);
447448

448-
if ((file= create_unique_file(fname,ptr)) < 0)
449+
if ((file= create_unique_file(fname, ptr,
450+
full_len - (size_t) (ptr - fname))) < 0)
449451
{
450452
error("Could not construct local filename %s%s.",
451453
target_dir_name,bname);
@@ -1227,7 +1229,6 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
12271229
exit(1);
12281230
}
12291231

1230-
memset(tmp_sql, 0, sizeof(tmp_sql));
12311232
snprintf(tmp_sql, sizeof(tmp_sql), " "
12321233
"SELECT Group_concat(cols) "
12331234
"FROM (SELECT 'op_type char(1)' cols "
@@ -1274,11 +1275,9 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
12741275
}
12751276
else
12761277
{
1277-
memset(tmp_sql, 0, sizeof(tmp_sql));
12781278
snprintf(tmp_sql, sizeof(tmp_sql), "__%s", map->get_table_name());
12791279
ev->set_flashback_review_tablename(tmp_sql);
12801280
}
1281-
memset(tmp_sql, 0, sizeof(tmp_sql));
12821281
tmp_sql_offset= snprintf(tmp_sql, sizeof(tmp_sql), "CREATE TABLE IF NOT EXISTS");
12831282
tmp_sql_offset+= snprintf(tmp_sql + tmp_sql_offset, sizeof(tmp_sql) - (uint) tmp_sql_offset, " `%s`.`%s` (%s) %s",
12841283
ev->get_flashback_review_dbname(),
@@ -1304,7 +1303,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
13041303
else
13051304
{
13061305
memset(tmp_str, 0, sizeof(tmp_str));
1307-
snprintf(tmp_str, sizeof(tmp_sql), "__%s", map->get_table_name());
1306+
snprintf(tmp_str, sizeof(tmp_str), "__%s", map->get_table_name());
13081307
ev->set_flashback_review_tablename(tmp_str);
13091308
}
13101309
}
@@ -2549,9 +2548,9 @@ static Exit_status check_master_version()
25492548
char buf[256];
25502549
rpl_gtid *start_gtid= &start_gtids[gtid_idx];
25512550

2552-
sprintf(buf, "%u-%u-%llu",
2553-
start_gtid->domain_id, start_gtid->server_id,
2554-
start_gtid->seq_no);
2551+
snprintf(buf, sizeof(buf), "%u-%u-%llu",
2552+
start_gtid->domain_id, start_gtid->server_id,
2553+
start_gtid->seq_no);
25552554
query_str.append(buf, strlen(buf));
25562555
if (gtid_idx < n_start_gtids - 1)
25572556
query_str.append(',');

0 commit comments

Comments
 (0)