]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_pubsub: Fix truncation of persisted SUBSCRIBE packet
authorSean Bright <sean.bright@gmail.com>
Thu, 14 Jan 2021 14:47:21 +0000 (09:47 -0500)
committerJoshua Colp <jcolp@sangoma.com>
Mon, 18 Jan 2021 16:27:33 +0000 (10:27 -0600)
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

res/res_pjsip_pubsub.c

index cf8baea6c83b85892f793369f54cf73ff07590db..dd088710fe3a83d9cb4f95a72fd6c9dbdd01ae01 100644 (file)
@@ -722,7 +722,7 @@ static void subscription_persistence_update(struct sip_subscription_tree *sub_tr
                        || 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));