diff mgw/mdcx.c @ 34:7dae2bae56a1

themwi-mgw: implement MDCX parameter validation
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Jul 2022 23:17:15 -0800
parents b3f74df7b808
children 020ba624bdd8
line wrap: on
line diff
--- a/mgw/mdcx.c	Sat Jul 09 22:52:44 2022 -0800
+++ b/mgw/mdcx.c	Sat Jul 09 23:17:15 2022 -0800
@@ -26,6 +26,22 @@
 			resp->res = TMGW_RESP_ERR_PROT;
 			return(-1);
 		}
+		if (req->gsm_addr.ss_family != AF_INET) {
+			resp->res = TMGW_RESP_ERR_PARAM;
+			return(-1);
+		}
+		switch (req->gsm_payload_msg_type) {
+		case GSM_TCHF_FRAME:
+			break;
+		case GSM_TCHF_FRAME_EFR:
+		case GSM_TCHH_FRAME:
+		case GSM_TCH_FRAME_AMR:
+			resp->res = TMGW_RESP_ERR_NOTSUP;
+			return(-1);
+		default:
+			resp->res = TMGW_RESP_ERR_PARAM;
+			return(-1);
+		}
 		bcopy(&req->gsm_addr, &ep->rtp_gsm.remote_addr,
 			sizeof(struct sockaddr_in));
 		ep->gsm_payload_type = req->gsm_payload_type;
@@ -36,6 +52,18 @@
 			resp->res = TMGW_RESP_ERR_PROT;
 			return(-1);
 		}
+		if (req->pstn_addr.ss_family != AF_INET) {
+			resp->res = TMGW_RESP_ERR_PARAM;
+			return(-1);
+		}
+		switch (req->pstn_payload_type) {
+		case PSTN_CODEC_PCMU:
+		case PSTN_CODEC_PCMA:
+			break;
+		default:
+			resp->res = TMGW_RESP_ERR_PARAM;
+			return(-1);
+		}
 		bcopy(&req->pstn_addr, &ep->rtp_pstn.remote_addr,
 			sizeof(struct sockaddr_in));
 		ep->pstn_payload_type = req->pstn_payload_type;