From cc9914f22d4c535d39e635403b2bf7494a64f685 Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Thu, 14 Jul 2022 16:45:59 +0200 Subject: [PATCH] sipsess/listen: fix UPDATE handling w/o SDP If a UAS receives an UPDATE without SDP, it MUST NOT send SDP in the response body. I.e. the target_refresh_handler only calls the offer handler (which sets the SDP) if it has received an INVITE or the request contained an SDP body. --- src/sipsess/listen.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/sipsess/listen.c b/src/sipsess/listen.c index d872002ea..dec7eb3bf 100644 --- a/src/sipsess/listen.c +++ b/src/sipsess/listen.c @@ -228,9 +228,10 @@ static void target_refresh_handler(struct sipsess_sock *sock, const struct sip_msg *msg) { struct sip *sip = sock->sip; - bool is_invite = true; + bool is_invite; + bool got_offer; struct sipsess *sess; - struct mbuf *desc; + struct mbuf *desc = NULL; char m[256]; int err; @@ -241,6 +242,8 @@ static void target_refresh_handler(struct sipsess_sock *sock, } is_invite = !pl_strcmp(&msg->met, "INVITE"); + got_offer = (mbuf_get_left(msg->mb) > 0); + if (!sip_dialog_rseq_valid(sess->dlg, msg)) { (void)sip_treply(NULL, sip, msg, 500, "Server Internal Error"); return; @@ -260,10 +263,13 @@ static void target_refresh_handler(struct sipsess_sock *sock, return; } - err = sess->offerh(&desc, msg, sess->arg); - if (err) { - (void)sip_reply(sip, msg, 488, str_error(err, m, sizeof(m))); - return; + if (got_offer || is_invite) { + err = sess->offerh(&desc, msg, sess->arg); + if (err) { + (void)sip_reply(sip, msg, 488, + str_error(err, m, sizeof(m))); + return; + } } (void)sip_dialog_update(sess->dlg, msg);