aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-09-01 20:17:47 +0200
committerlaforge <laforge@osmocom.org>2020-09-02 10:24:34 +0000
commit75b3cba5fcd43f372d3486616f526e5bef9e8cc2 (patch)
treebc3eb4b1ee13b905aa332ece0fd3cd73679c884d
parent783960f4d95ceb4d8e217c34cbf1f3f33cb7cd23 (diff)
Fail on invalid IP addresses passed to IPACC MDCX
IPACC protocol supports only IPv4 addresses, so make sure if an IPv6 address (or whatever malformed address) is caught is not sent without noticing. Prior to this patch, faulty addresses would be sent over the wire as 255.255.255.255 (-1 returned from inet_addr()). Change-Id: Iee84e8b40cdede1cacd8e8a9e26dda0d85383ec8
-rw-r--r--src/osmo-bsc/lchan_rtp_fsm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/osmo-bsc/lchan_rtp_fsm.c b/src/osmo-bsc/lchan_rtp_fsm.c
index 1fe545286..1dd31b134 100644
--- a/src/osmo-bsc/lchan_rtp_fsm.c
+++ b/src/osmo-bsc/lchan_rtp_fsm.c
@@ -330,6 +330,7 @@ static void lchan_rtp_fsm_wait_ipacc_mdcx_ack_onenter(struct osmo_fsm_inst *fi,
int rc;
struct gsm_lchan *lchan = lchan_rtp_fi_lchan(fi);
const struct mgcp_conn_peer *mgw_rtp;
+ struct in_addr sin;
if (lchan->release.requested) {
lchan_rtp_fail("Release requested while activating");
@@ -344,8 +345,13 @@ static void lchan_rtp_fsm_wait_ipacc_mdcx_ack_onenter(struct osmo_fsm_inst *fi,
return;
}
- /* Other RTP settings were already setup in lchan_rtp_fsm_wait_ipacc_crcx_ack_onenter() */
- lchan->abis_ip.connect_ip = ntohl(inet_addr(mgw_rtp->addr));
+ /* Other RTP settings were already set up in lchan_rtp_fsm_wait_ipacc_crcx_ack_onenter() */
+ if (inet_pton(AF_INET, mgw_rtp->addr, &sin) != 1) {
+ /* Only IPv4 addresses are supported in IPACC */
+ lchan_rtp_fail("Invalid remote IPv4 address %s", mgw_rtp->addr);
+ return;
+ }
+ lchan->abis_ip.connect_ip = ntohl(sin.s_addr);
lchan->abis_ip.connect_port = mgw_rtp->port;
/* send-recv */