]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk: Ensure sufficient space for worst case NACK.
authorJoshua C. Colp <jcolp@sangoma.com>
Wed, 25 Mar 2020 09:38:53 +0000 (06:38 -0300)
committerJoshua Colp <jcolp@sangoma.com>
Thu, 26 Mar 2020 13:36:58 +0000 (08:36 -0500)
ASTERISK-28790

Change-Id: I10df52f98b19ed62575f25dab36e82d136dccd99

res/res_rtp_asterisk.c

index 05a993ff86e98e052457f6dc34bab8a9a998fb67..47562f510c6b15cc91376797e09bdac0e553d899 100644 (file)
@@ -7964,12 +7964,15 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
                        int res = 0;
                        int ice;
                        int sr;
-                       size_t data_size = AST_UUID_STR_LEN + 128 + (seqno - rtp->expectedrxseqno) / 17;
+                       size_t data_size = AST_UUID_STR_LEN + 128 + (AST_VECTOR_SIZE(&rtp->missing_seqno) * 4);
                        RAII_VAR(unsigned char *, rtcpheader, NULL, ast_free_ptr);
                        RAII_VAR(struct ast_rtp_rtcp_report *, rtcp_report,
                                        ast_rtp_rtcp_report_alloc(rtp->themssrc_valid ? 1 : 0),
                                        ao2_cleanup);
 
+                       /* Sufficient space for RTCP headers and report, SDES with CNAME, NACK header,
+                        * and worst case 4 bytes per missing sequence number.
+                        */
                        rtcpheader = ast_malloc(sizeof(*rtcpheader) + data_size);
                        if (!rtcpheader) {
                                ast_debug(1, "Failed to allocate memory for NACK\n");