From c546b6b89f998f18ac4b7eaf472fd6d00f239597 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 6 Dec 2018 03:26:54 -0500 Subject: [PATCH] TT#45472 check a=mid values in answers and warn on mismatches Change-Id: I49b359db40b984abb8a46407145d5adeb7e19cfa --- daemon/call.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/daemon/call.c b/daemon/call.c index cbe77bd6e..4aeb620bb 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1702,6 +1702,22 @@ static void __update_media_id(struct call_media *media, struct call_media *other g_hash_table_insert(ml->media_ids, &media->media_id, media); } } + else if (flags->opmode == OP_ANSWER) { + // in normal cases, if the answer contains a media ID, it must match + // the media ID previously sent in the offer, as the order of the media + // sections must remain intact (RFC 5888 section 9.1). check this. + if (sp->media_id.s) { + if (!other_media->media_id.s) + ilog(LOG_INFO, "Received answer SDP with media ID ('" + STR_FORMAT "') when no media ID was offered", + STR_FMT(&sp->media_id)); + else if (str_cmp_str(&other_media->media_id, &sp->media_id)) + ilog(LOG_WARN, "Received answer SDP with mismatched media ID ('" + STR_FORMAT "') when the offered media ID was '" + STR_FORMAT "'", + STR_FMT(&sp->media_id), STR_FMT(&other_media->media_id)); + } + } } /* called with call->master_lock held in W */