if (SlotIsPhysical(slot))
return;
- memcpy(&msg.m_slotname, name, NAMEDATALEN);
+ strlcpy(msg.m_slotname, name, NAMEDATALEN);
msg.clearall = false;
}
else
* Prepare and send the message
*/
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_REPLSLOT);
- memcpy(&msg.m_slotname, slotname, NAMEDATALEN);
+ strlcpy(msg.m_slotname, slotname, NAMEDATALEN);
msg.m_drop = false;
msg.m_spill_txns = spilltxns;
msg.m_spill_count = spillcount;
PgStat_MsgReplSlot msg;
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_REPLSLOT);
- memcpy(&msg.m_slotname, slotname, NAMEDATALEN);
+ strlcpy(msg.m_slotname, slotname, NAMEDATALEN);
msg.m_drop = true;
pgstat_send(&msg, sizeof(PgStat_MsgReplSlot));
}
if (idx < 0)
return;
- Assert(idx >= 0 && idx <= max_replication_slots);
+ /* it must be a valid replication slot index */
+ Assert(idx >= 0 && idx < max_replication_slots);
+
if (msg->m_drop)
{
/* Remove the replication slot statistics with the given name */
/* Register new slot */
memset(&replSlotStats[nReplSlotStats], 0, sizeof(PgStat_ReplSlotStats));
- memcpy(&replSlotStats[nReplSlotStats].slotname, name, NAMEDATALEN);
+ strlcpy(replSlotStats[nReplSlotStats].slotname, name, NAMEDATALEN);
return nReplSlotStats++;
}