@@ -900,7 +900,7 @@ MtmCreateTransState(MtmCurrentTrans* x)
900
900
ts -> gtid .xid = x -> xid ;
901
901
ts -> gtid .node = MtmNodeId ;
902
902
}
903
- strcpy (ts -> gid , x -> gid );
903
+ strncpy (ts -> gid , x -> gid , GIDSIZE );
904
904
x -> isActive = true;
905
905
906
906
Assert (ts -> gid [0 ] == '\0' || MtmGidParseNodeId (ts -> gid ) == ts -> gtid .node );
@@ -1430,7 +1430,7 @@ MtmLogAbortLogicalMessage(int nodeId, char const* gid)
1430
1430
{
1431
1431
MtmAbortLogicalMessage msg ;
1432
1432
lsn_t lsn ;
1433
- strcpy (msg .gid , gid );
1433
+ strncpy (msg .gid , gid , GIDSIZE );
1434
1434
msg .origin_node = nodeId ;
1435
1435
msg .origin_lsn = replorigin_session_origin_lsn ;
1436
1436
lsn = LogLogicalMessage ("A" , (char * )& msg , sizeof msg , false);
@@ -1525,7 +1525,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
1525
1525
ts -> gtid = x -> gtid ;
1526
1526
ts -> nSubxids = 0 ;
1527
1527
ts -> votingCompleted = true;
1528
- strcpy (ts -> gid , x -> gid );
1528
+ strncpy (ts -> gid , x -> gid , GIDSIZE );
1529
1529
MtmTransactionListAppend (ts );
1530
1530
if (* x -> gid ) {
1531
1531
replorigin_session_origin_lsn = INVALID_LSN ;
@@ -1682,7 +1682,7 @@ static void MtmLoadPreparedTransactions(void)
1682
1682
ts -> participantsMask = (((nodemask_t )1 << Mtm -> nAllNodes ) - 1 ) & ~((nodemask_t )1 << (MtmNodeId - 1 ));
1683
1683
ts -> nConfigChanges = Mtm -> nConfigChanges ;
1684
1684
ts -> votedMask = 0 ;
1685
- strcpy (ts -> gid , gid );
1685
+ strncpy (ts -> gid , gid , GIDSIZE );
1686
1686
MtmTransactionListAppend (ts );
1687
1687
tm -> status = ts -> status ;
1688
1688
tm -> state = ts ;
@@ -1763,7 +1763,7 @@ void MtmJoinTransaction(GlobalTransactionId* gtid, csn_t globalSnapshot, nodemas
1763
1763
void MtmSetCurrentTransactionGID (char const * gid )
1764
1764
{
1765
1765
MTM_LOG3 ("Set current transaction xid=" XID_FMT " GID %s" , MtmTx .xid , gid );
1766
- strcpy (MtmTx .gid , gid );
1766
+ strncpy (MtmTx .gid , gid , GIDSIZE );
1767
1767
MtmTx .isDistributed = true;
1768
1768
MtmTx .isReplicated = true;
1769
1769
MtmTx .gtid .node = MtmGidParseNodeId (gid );
@@ -2546,7 +2546,7 @@ void MtmUpdateNodeConnectionInfo(MtmConnectionInfo* conn, char const* connStr)
2546
2546
while (isspace (* connStr ))
2547
2547
connStr ++ ;
2548
2548
2549
- strcpy (conn -> connStr , connStr );
2549
+ strncpy (conn -> connStr , connStr , MULTIMASTER_MAX_CONN_STR_SIZE );
2550
2550
2551
2551
host = strstr (connStr , "host=" );
2552
2552
if (host == NULL ) {
@@ -5053,12 +5053,12 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5053
5053
break ;
5054
5054
case TRANS_STMT_PREPARE :
5055
5055
MtmTx .isTwoPhase = true;
5056
- strcpy (MtmTx .gid , stmt -> gid );
5056
+ strncpy (MtmTx .gid , stmt -> gid , GIDSIZE );
5057
5057
break ;
5058
5058
case TRANS_STMT_COMMIT_PREPARED :
5059
5059
case TRANS_STMT_ROLLBACK_PREPARED :
5060
5060
Assert (!MtmTx .isTwoPhase );
5061
- strcpy (MtmTx .gid , stmt -> gid );
5061
+ strncpy (MtmTx .gid , stmt -> gid , GIDSIZE );
5062
5062
break ;
5063
5063
default :
5064
5064
break ;
0 commit comments