Skip to content

Commit

Permalink
sip/transp: add essential fields check (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiqi Wang authored Jun 24, 2021
1 parent 3160245 commit f6db77d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,18 @@ static void conn_keepalive_handler(void *arg)
conn_keepalive_handler, conn);
}

static bool have_essential_fields(const struct sip_msg *msg)
{
if (pl_isset(&(msg->to.auri)) &&
pl_isset(&(msg->from.auri)) &&
pl_isset(&(msg->cseq.met)) &&
pl_isset(&(msg->callid)) &&
pl_isset(&(msg->maxfwd)) &&
pl_isset(&(msg->via.branch)))
return true;

return false;
}

static void sip_recv(struct sip *sip, const struct sip_msg *msg,
size_t start)
Expand All @@ -291,6 +303,13 @@ static void sip_recv(struct sip *sip, const struct sip_msg *msg,
sip->arg);
}

if (msg->req) {
if (!have_essential_fields(msg)){
(void)sip_reply(sip, msg, 400, "Bad Request");
return;
}
}

while (le) {
struct sip_lsnr *lsnr = le->data;

Expand Down

0 comments on commit f6db77d

Please sign in to comment.