Skip to content

Commit

Permalink
tm: remove cluster received '\0' from buffer len
Browse files Browse the repository at this point in the history
When sending a message through cluster, the tm module adds a '\0'
terminator to the message - that is because receive_msg expects it.
However, this character should not be part of the message lenght.

Reported by Denys Pozniak on mailing lists.
  • Loading branch information
razvancrainea committed Jan 9, 2023
1 parent 8c613f8 commit 81e9b14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/tm/cluster.c
Expand Up @@ -207,6 +207,8 @@ static void receive_tm_repl(bin_packet_t *packet)
memcpy((char *)&ri.src_ip, tmp.s, tmp.len);
TM_BIN_POP(int, &ri.src_port, "src port");
TM_BIN_POP(str, &tmp, "message");
/* we need to substract the '\0' termination from message len */
tmp.len--;

/* only auto-CANCEL is treated differently */
switch (packet->type) {
Expand Down Expand Up @@ -322,7 +324,7 @@ static bin_packet_t *tm_replicate_packet(struct sip_msg *msg, int type)
TM_BIN_PUSH(str, &tmp, "src host");
TM_BIN_PUSH(int, msg->rcv.src_port, "src port");
tmp.s = msg->buf;
tmp.len = msg->len + 1; /* XXX: add null terminator */
tmp.len = msg->len + 1; /* XXX: add '\0' terminator - receive_msg expects it */
TM_BIN_PUSH(str, &tmp, "message");

return &packet;
Expand Down

0 comments on commit 81e9b14

Please sign in to comment.