[Asterisk-code-review] res_pjsip_pubsub: Fix truncation of persisted SUBSCRIBE packet (asterisk[16])

Joshua Colp asteriskteam at digium.com
Mon Jan 18 09:58:46 CST 2021


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15324 )

Change subject: res_pjsip_pubsub: Fix truncation of persisted SUBSCRIBE packet
......................................................................

res_pjsip_pubsub: Fix truncation of persisted SUBSCRIBE packet

The last argument to ast_copy_string() is the buffer size, not the
number of characters, so we add 1 to avoid stamping out the final \n
in the persisted SUBSCRIBE message.

Change-Id: I019b78942836f57965299af15d173911fcead5b2
---
M res/res_pjsip_pubsub.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index cf8baea..dd08871 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -722,7 +722,7 @@
 			|| type == SUBSCRIPTION_PERSISTENCE_RECREATED) {
 			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));
+						MIN(sizeof(sub_tree->persistence->packet), rdata->msg_info.len + 1));
 			} else {
 				ast_copy_string(sub_tree->persistence->packet, rdata->pkt_info.packet,
 						sizeof(sub_tree->persistence->packet));

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15324
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I019b78942836f57965299af15d173911fcead5b2
Gerrit-Change-Number: 15324
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210118/87ef449e/attachment.html>


More information about the asterisk-code-review mailing list