Skip to content

Commit

Permalink
sipsess/listen: fix UPDATE handling w/o SDP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maximilianfridrich authored and sreimers committed Jul 16, 2022
1 parent 90d03d4 commit cc9914f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/sipsess/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit cc9914f

Please sign in to comment.