Skip to content

Commit 6eee4e2

Browse files
committed
Merge branch 'bb-10.11-release' into bb-11.4-release
2 parents e1972bc + 4d06d7b commit 6eee4e2

530 files changed

Lines changed: 9214 additions & 8634 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(getenv(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 &&
@@ -3669,7 +3672,7 @@ static int com_go(String *buffer, char *)
36693672
}
36703673

36713674
if (verbose >= 3 || !opt_silent)
3672-
end_timer(timer, time_buff);
3675+
end_timer(timer, time_buff, sizeof(time_buff));
36733676
else
36743677
time_buff[0]= '\0';
36753678

@@ -3705,9 +3708,9 @@ static int com_go(String *buffer, char *)
37053708
print_tab_data(result);
37063709
else
37073710
print_table_data(result);
3708-
snprintf(buff, sizeof(buff), "%ld %s in set",
3709-
(long) mysql_num_rows(result),
3710-
(long) mysql_num_rows(result) == 1 ? "row" : "rows");
3711+
snprintf(buff, sizeof(buff), "%llu %s in set",
3712+
(unsigned long long) mysql_num_rows(result),
3713+
mysql_num_rows(result) == 1 ? "row" : "rows");
37113714
end_pager();
37123715
if (mysql_errno(&mysql))
37133716
{
@@ -3721,7 +3724,7 @@ static int com_go(String *buffer, char *)
37213724
strmov(buff,"Query OK");
37223725
else
37233726
snprintf(buff, sizeof(buff), "Query OK, %llu %s affected",
3724-
mysql_affected_rows(&mysql),
3727+
(unsigned long long) mysql_affected_rows(&mysql),
37253728
mysql_affected_rows(&mysql) == 1 ? "row" : "rows");
37263729

37273730
pos=strend(buff);
@@ -3900,7 +3903,7 @@ static char *fieldflags2str(uint f) {
39003903
ff2s_check_flag(ON_UPDATE_NOW);
39013904
#undef ff2s_check_flag
39023905
if (f)
3903-
snprintf(s, sizeof(buf), " unknows=0x%04x", f);
3906+
snprintf(s, sizeof(buf) - (size_t)(s - buf), " unknown=0x%04x", f);
39043907
return buf;
39053908
}
39063909

@@ -4641,8 +4644,10 @@ com_edit(String *buffer,char *)
46414644
strxmov(buff,editor," ",filename,NullS);
46424645
if ((error= system(buff)))
46434646
{
4644-
char errmsg[100];
4645-
snprintf(errmsg, sizeof(errmsg), "Command '%.40s' failed", buff);
4647+
#define EDITOR_FAIL_MSG "Command '%.40s' failed"
4648+
char errmsg[sizeof(EDITOR_FAIL_MSG) - 1 + 40];
4649+
snprintf(errmsg, sizeof(errmsg), EDITOR_FAIL_MSG, buff);
4650+
#undef EDITOR_FAIL_MSG
46464651
put_info(errmsg, INFO_ERROR, 0, NullS);
46474652
goto err;
46484653
}
@@ -5338,7 +5343,7 @@ static int com_status(String *, char *)
53385343
tee_fprintf(stdout, "%.*s\t\t\t", (int) (pos-status_str), status_str);
53395344
if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec)))
53405345
{
5341-
nice_time((double) sec,buff,0);
5346+
nice_time((double) sec,buff, sizeof(buff),0);
53425347
tee_puts(buff, stdout); /* print nice time */
53435348
while (*status_str == ' ')
53445349
status_str++; /* to next info */
@@ -5557,8 +5562,10 @@ void tee_putc(int c, FILE *file)
55575562
55585563
len("4294967296 days, 23 hours, 59 minutes, 60.000 seconds") -> 53
55595564
*/
5560-
static void nice_time(double sec, char *buff, bool part_second)
5565+
static void nice_time(double sec, char *buff, size_t buff_size,
5566+
bool part_second)
55615567
{
5568+
char *buff_end= buff + buff_size;
55625569
ulong tmp;
55635570
if (sec >= 3600.0*24)
55645571
{
@@ -5582,21 +5589,23 @@ static void nice_time(double sec, char *buff, bool part_second)
55825589
buff=strmov(buff," min ");
55835590
}
55845591
if (part_second)
5585-
sprintf(buff,"%.3f sec",sec);
5592+
snprintf(buff, buff_end - buff, "%.3f sec", sec);
55865593
else
5587-
sprintf(buff,"%d sec",(int) sec);
5594+
snprintf(buff, buff_end - buff, "%d sec", (int) sec);
55885595
}
55895596

55905597

5591-
static void end_timer(ulonglong start_time, char *buff)
5598+
static void end_timer(ulonglong start_time, char *buff, size_t buff_size)
55925599
{
55935600
double sec;
55945601

5602+
if (buff_size < 4)
5603+
return;
55955604
buff[0]=' ';
55965605
buff[1]='(';
55975606
sec= (microsecond_interval_timer() - start_time) / (double) (1000 * 1000);
5598-
nice_time(sec, buff + 2, 1);
5599-
strmov(strend(buff),")");
5607+
nice_time(sec, buff + 2, buff_size - 2, 1);
5608+
snprintf(strend(buff), buff_size - (strend(buff) - buff), ")");
56005609
}
56015610

56025611
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
@@ -721,7 +721,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
721721

722722
if (opt_shutdown_wait_for_slaves)
723723
{
724-
sprintf(buff, "SHUTDOWN WAIT FOR ALL SLAVES");
724+
snprintf(buff, sizeof(buff), "SHUTDOWN WAIT FOR ALL SLAVES");
725725
if (mysql_query(mysql, buff))
726726
{
727727
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
@@ -312,13 +312,14 @@ class Load_log_processor
312312
@retval -1 Error (can't find new filename).
313313
@retval >=0 Found file.
314314
*/
315-
File create_unique_file(char *filename, char *file_name_end)
315+
File create_unique_file(char *filename, char *file_name_end,
316+
size_t buf_remaining)
316317
{
317318
File res;
318319
/* If we have to try more than 1000 times, something is seriously wrong */
319320
for (uint version= 0; version<1000; version++)
320321
{
321-
sprintf(file_name_end,"-%x",version);
322+
snprintf(file_name_end, buf_remaining, "-%x", version);
322323
if ((res= my_create(filename,0,
323324
O_CREAT|O_EXCL|O_BINARY|O_WRONLY,MYF(0)))!=-1)
324325
return res;
@@ -444,7 +445,8 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
444445
//so the rest of fname has size full_len - target_dir_name_len
445446
ptr+= snprintf(ptr, full_len - target_dir_name_len, "-%x", file_id);
446447

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

1229-
memset(tmp_sql, 0, sizeof(tmp_sql));
12301231
snprintf(tmp_sql, sizeof(tmp_sql), " "
12311232
"SELECT Group_concat(cols) "
12321233
"FROM (SELECT 'op_type char(1)' cols "
@@ -1273,11 +1274,9 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
12731274
}
12741275
else
12751276
{
1276-
memset(tmp_sql, 0, sizeof(tmp_sql));
12771277
snprintf(tmp_sql, sizeof(tmp_sql), "__%s", map->get_table_name());
12781278
ev->set_flashback_review_tablename(tmp_sql);
12791279
}
1280-
memset(tmp_sql, 0, sizeof(tmp_sql));
12811280
tmp_sql_offset= snprintf(tmp_sql, sizeof(tmp_sql), "CREATE TABLE IF NOT EXISTS");
12821281
tmp_sql_offset+= snprintf(tmp_sql + tmp_sql_offset, sizeof(tmp_sql) - (uint) tmp_sql_offset, " `%s`.`%s` (%s) %s",
12831282
ev->get_flashback_review_dbname(),
@@ -1303,7 +1302,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
13031302
else
13041303
{
13051304
memset(tmp_str, 0, sizeof(tmp_str));
1306-
snprintf(tmp_str, sizeof(tmp_sql), "__%s", map->get_table_name());
1305+
snprintf(tmp_str, sizeof(tmp_str), "__%s", map->get_table_name());
13071306
ev->set_flashback_review_tablename(tmp_str);
13081307
}
13091308
}
@@ -2541,9 +2540,9 @@ static Exit_status check_master_version()
25412540
char buf[256];
25422541
rpl_gtid *start_gtid= &start_gtids[gtid_idx];
25432542

2544-
sprintf(buf, "%u-%u-%llu",
2545-
start_gtid->domain_id, start_gtid->server_id,
2546-
start_gtid->seq_no);
2543+
snprintf(buf, sizeof(buf), "%u-%u-%llu",
2544+
start_gtid->domain_id, start_gtid->server_id,
2545+
start_gtid->seq_no);
25472546
query_str.append(buf, strlen(buf));
25482547
if (gtid_idx < n_start_gtids - 1)
25492548
query_str.append(',');

0 commit comments

Comments
 (0)