Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add essential fields check #119

Merged
merged 3 commits into from
Jun 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,21 @@ 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;
}
else {
sreimers marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

}

static void sip_recv(struct sip *sip, const struct sip_msg *msg,
size_t start)
Expand All @@ -299,6 +314,13 @@ static void sip_recv(struct sip *sip, const struct sip_msg *msg,
if (msg->req != lsnr->req)
continue;

if (msg->req) {
if (!have_essential_fields(msg)){
I-mpossible marked this conversation as resolved.
Show resolved Hide resolved
(void)sip_reply(sip, msg, 400, "Bad Request");
return;
}
}

if (lsnr->msgh(msg, lsnr->arg))
return;
}
Expand Down