Change in osmo-mgw[master]: mgcp_trunk: check MGW domain name earlier

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Aug 2 09:17:11 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/25099 )

Change subject: mgcp_trunk: check MGW domain name earlier
......................................................................

mgcp_trunk: check MGW domain name earlier

The MGW domain name is usually checked while resolving the endpoint
after the trunk has been resolved. This was no problem before, but since
we allow wildcarded DLCX requests, which require only a trunk to work,
the check is not done correctly for wildcarded DLCX requests and invalid
domain names may slip through.

Checking the domain name earlier while the trunk is resolved makes sense
and it fixes the problem.

Change-Id: I9944a9103981fb5f4d0d8714ee2847ae020f76df
---
M src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_trunk.c
2 files changed, 30 insertions(+), 30 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 41e0d4f..16043d4 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -300,32 +300,6 @@
 	return NULL;
 }
 
-/* Check if the domain name, which is supplied with the endpoint name
- * matches the configuration. */
-static int check_domain_name(const char *epname, struct mgcp_config *cfg)
-{
-	char *domain_to_check;
-
-	domain_to_check = strstr(epname, "@");
-	if (!domain_to_check) {
-		LOGP(DLMGCP, LOGL_ERROR, "missing domain name in endpoint name \"%s\", expecting \"%s\"\n",
-		     epname, cfg->domain);
-		return -EINVAL;
-	}
-
-	/* Accept any domain if configured as "*" */
-	if (!strcmp(cfg->domain, "*"))
-		return 0;
-
-	if (strcmp(domain_to_check+1, cfg->domain) != 0) {
-		LOGP(DLMGCP, LOGL_ERROR, "wrong domain name in endpoint name \"%s\", expecting \"%s\"\n",
-		     epname, cfg->domain);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 /*! Find an endpoint by its name, search at all trunks.
  *  \param[out] cause, pointer to store cause code, can be NULL.
  *  \param[in] epname, must contain trunk prefix.
@@ -349,10 +323,6 @@
 	if (!trunk)
 		return NULL;
 
-	/* All endpoint names require a domain as suffix */
-	if (check_domain_name(epname, cfg))
-		return NULL;
-
 	/* Identify the endpoint on the trunk */
         endp = mgcp_endp_by_name_trunk(cause, epname, trunk);
 	if (!endp) {
diff --git a/src/libosmo-mgcp/mgcp_trunk.c b/src/libosmo-mgcp/mgcp_trunk.c
index 27663b4..73de972 100644
--- a/src/libosmo-mgcp/mgcp_trunk.c
+++ b/src/libosmo-mgcp/mgcp_trunk.c
@@ -206,6 +206,32 @@
 	}
 }
 
+/* Check if the domain name, which is supplied with the endpoint name
+ * matches the configuration. */
+static int check_domain_name(const char *epname, const struct mgcp_config *cfg)
+{
+	char *domain_to_check;
+
+	domain_to_check = strstr(epname, "@");
+	if (!domain_to_check) {
+		LOGP(DLMGCP, LOGL_ERROR, "missing domain name in endpoint name \"%s\", expecting \"%s\"\n",
+		     epname, cfg->domain);
+		return -EINVAL;
+	}
+
+	/* Accept any domain if configured as "*" */
+	if (!strcmp(cfg->domain, "*"))
+		return 0;
+
+	if (strcmp(domain_to_check+1, cfg->domain) != 0) {
+		LOGP(DLMGCP, LOGL_ERROR, "wrong domain name in endpoint name \"%s\", expecting \"%s\"\n",
+		     epname, cfg->domain);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*! Find a trunk by the trunk prefix in the endpoint name.
  *  \param[in] epname endpoint name with trunk prefix to look up.
  *  \param[in] cfg that contains the trunks where the endpoint is located.
@@ -220,6 +246,10 @@
 	osmo_str_tolower_buf(epname_lc, sizeof(epname_lc), epname);
 	epname = epname_lc;
 
+	/* All endpoint names require a domain as suffix */
+	if (check_domain_name(epname, cfg))
+		return NULL;
+
 	prefix_len = sizeof(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK) - 1;
 	if (strncmp(epname, MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, prefix_len) == 0) {
 		return mgcp_trunk_by_num(cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/25099
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I9944a9103981fb5f4d0d8714ee2847ae020f76df
Gerrit-Change-Number: 25099
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210802/a584ff0e/attachment.htm>


More information about the gerrit-log mailing list