diff options
-rw-r--r-- | res/res_pjsip_pubsub.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index 8cd5b7bf1..d409a8eaf 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -561,8 +561,19 @@ static void subscription_persistence_update(struct sip_subscription_tree *sub_tr expires = expires_hdr ? expires_hdr->ivalue : DEFAULT_PUBLISH_EXPIRES; sub_tree->persistence->expires = ast_tvadd(ast_tvnow(), ast_samp2tv(expires, 1)); - pjsip_msg_print(rdata->msg_info.msg, sub_tree->persistence->packet, - sizeof(sub_tree->persistence->packet)); + /* When receiving a packet on an streaming transport, it's possible to receive more than one SIP + * message at a time into the rdata->pkt_info.packet buffer. However, the rdata->msg_info.msg_buf + * will always point to the proper SIP message that is to be processed. When updating subscription + * persistence that is pulled from persistent storage, though, the rdata->pkt_info.packet will + * only ever have a single SIP message on it, and so we base persistence on that. + */ + if (rdata->msg_info.msg_buf) { + ast_copy_string(sub_tree->persistence->packet, rdata->msg_info.msg_buf, + MIN(sizeof(sub_tree->persistence->packet), rdata->msg_info.len)); + } else { + ast_copy_string(sub_tree->persistence->packet, rdata->pkt_info.packet, + sizeof(sub_tree->persistence->packet)); + } ast_copy_string(sub_tree->persistence->src_name, rdata->pkt_info.src_name, sizeof(sub_tree->persistence->src_name)); sub_tree->persistence->src_port = rdata->pkt_info.src_port; |