changeset 50:daf1c26d7ae2

sip-in: check INVITE Content-Type header
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 06 Sep 2022 23:50:16 -0800
parents dec31b1a8b96
children 36a30349b490
files sip-in/invite.c
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sip-in/invite.c	Tue Sep 06 22:57:16 2022 -0800
+++ b/sip-in/invite.c	Tue Sep 06 23:50:16 2022 -0800
@@ -18,6 +18,8 @@
 
 extern int cfg_use_100rel;
 
+extern char *get_single_header();
+
 void
 handle_sip_invite(req, ess, sin)
 	struct sip_pkt_rx *req;
@@ -27,7 +29,7 @@
 	char uri_user[13], *called_nanp;
 	struct sip_msg_out resp;
 	struct supported_ext supp_ext;
-	char *unsup_ext;
+	char *hval, *unsup_ext;
 	int ext_100rel_req, ext_100rel_sup, use_100rel;
 	int rc;
 
@@ -92,6 +94,24 @@
 		use_100rel = cfg_use_100rel;
 	else
 		use_100rel = 0;
+	/* did the caller send an SDP message body? */
+	if (!req->msg_body_len) {
+		start_response_out_msg(&resp, "415 Missing SDP body");
+error_415:	rc = out_msg_add_header(&resp, "Accept", "application/sdp");
+		if (rc < 0)
+			goto error_resp_toolong;
+		goto error_resp;
+	}
+	hval = get_single_header(req, "Content-Type", "c", (int *) 0);
+	if (!hval) {
+		start_response_out_msg(&resp,
+			"415 Missing Content-Type header");
+		goto error_415;
+	}
+	if (strcasecmp(hval, "application/sdp")) {
+		start_response_out_msg(&resp, "415 Unsupported Content-Type");
+		goto error_415;
+	}
 	/*
 	 * Remaining checks to be implemented:
 	 * SDP message body