From 799773b5ca84419db889267e05f83509f4dedfb2 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 4 Mar 2022 09:05:09 -0500 Subject: [PATCH] TT#14008 fix format list printing logic Explicitly copy SDP up to the format list before printing it out. This preserves broken input SDP. closes #1461 Change-Id: I839a200f159f25854c86add244571a948e2c90cf --- daemon/sdp.c | 11 ++++++--- t/auto-daemon-tests.pl | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/daemon/sdp.c b/daemon/sdp.c index 76fe18a37..05e7302b1 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1825,7 +1825,6 @@ static int replace_transport_protocol(struct sdp_chopper *chop, static int print_format_str(GString *s, struct call_media *cm) { if (!cm->format_str.s) return 0; - g_string_append(s, " "); g_string_append_len(s, cm->format_str.s, cm->format_str.len); return 0; } @@ -1839,7 +1838,9 @@ static int print_codec_list(GString *s, struct call_media *media) { for (GList *l = media->codecs.codec_prefs.head; l; l = l->next) { struct rtp_payload_type *pt = l->data; - g_string_append_printf(s, " %u", pt->payload_type); + if (l != media->codecs.codec_prefs.head) + g_string_append_c(s, ' '); + g_string_append_printf(s, "%u", pt->payload_type); } return 0; } @@ -1847,6 +1848,8 @@ static int print_codec_list(GString *s, struct call_media *media) { static int replace_codec_list(struct sdp_chopper *chop, struct sdp_media *media, struct call_media *cm) { + if (copy_up_to(chop, &media->formats)) + return -1; if (skip_over(chop, &media->formats)) return -1; @@ -2865,12 +2868,12 @@ int sdp_create(str *out, struct call_monologue *monologue, struct sdp_ng_flags * goto err; err = "Unknown media protocol"; if (media->protocol) - g_string_append_printf(s, "m=" STR_FORMAT " %i %s", + g_string_append_printf(s, "m=" STR_FORMAT " %i %s ", STR_FMT(&media->type), rtp_ps->selected_sfd->socket.local.port, media->protocol->name); else if (media->protocol_str.s) - g_string_append_printf(s, "m=" STR_FORMAT " %i " STR_FORMAT, + g_string_append_printf(s, "m=" STR_FORMAT " %i " STR_FORMAT " ", STR_FMT(&media->type), rtp_ps->selected_sfd->socket.local.port, STR_FMT(&media->protocol_str)); diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 036c84b39..1738dc812 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -15085,4 +15085,60 @@ a=rtcp:PORT SDP + +new_call; + +offer('GH #1461', { }, <