Skip to content

Commit f615901

Browse files
committed
Bug#17760511: COVERITY ANALYSIS RESULTS AND PATCHES
Bug#70830: Coverity analysis results and patches Fix more issues found by Coverty. Based on patches contributed by Honza Horak.
1 parent 691637d commit f615901

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

plugin/semisync/semisync_master.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
557557

558558
if (need_copy_send_pos)
559559
{
560-
strcpy(reply_file_name_, log_file_name);
560+
strncpy(reply_file_name_, log_file_name, sizeof(reply_file_name_) - 1);
561+
reply_file_name_[sizeof(reply_file_name_) - 1]= '\0';
561562
reply_file_pos_ = log_file_pos;
562563
reply_file_name_inited_ = true;
563564

@@ -685,7 +686,8 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
685686
if (cmp <= 0)
686687
{
687688
/* This thd has a lower position, let's update the minimum info. */
688-
strcpy(wait_file_name_, trx_wait_binlog_name);
689+
strncpy(wait_file_name_, trx_wait_binlog_name, sizeof(wait_file_name_) - 1);
690+
wait_file_name_[sizeof(wait_file_name_) - 1]= '\0';
689691
wait_file_pos_ = trx_wait_binlog_pos;
690692

691693
rpl_semi_sync_master_wait_pos_backtraverse++;
@@ -696,7 +698,8 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
696698
}
697699
else
698700
{
699-
strcpy(wait_file_name_, trx_wait_binlog_name);
701+
strncpy(wait_file_name_, trx_wait_binlog_name, sizeof(wait_file_name_) - 1);
702+
wait_file_name_[sizeof(wait_file_name_) - 1]= '\0';
700703
wait_file_pos_ = trx_wait_binlog_pos;
701704
wait_file_name_inited_ = true;
702705

sql/sp_rcontext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ class sp_rcontext : public Sql_alloc
144144
memcpy(sql_state, _sql_state, SQLSTATE_LENGTH);
145145
sql_state[SQLSTATE_LENGTH]= '\0';
146146

147-
strncpy(message, _message, MYSQL_ERRMSG_SIZE);
147+
strncpy(message, _message, MYSQL_ERRMSG_SIZE - 1);
148+
message[MYSQL_ERRMSG_SIZE - 1]= '\0';
148149
}
149150
};
150151

strings/ctype-ucs2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ my_utf32_uni(const CHARSET_INFO *cs __attribute__((unused)),
19271927
{
19281928
if (s + 4 > e)
19291929
return MY_CS_TOOSMALL4;
1930-
*pwc= (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + (s[3]);
1930+
*pwc= (((my_wc_t)s[0]) << 24) + (s[1] << 16) + (s[2] << 8) + (s[3]);
19311931
return 4;
19321932
}
19331933

0 commit comments

Comments
 (0)