Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13665


Change subject: mgcp-client: Sanitize implementation of 
mgcp_client_rtpbridge_wildcard
......................................................................

mgcp-client: Sanitize implementation of mgcp_client_rtpbridge_wildcard

* Get rid of string define containing printf statements
* Split name from rest of checks to easily add new names later

Change-Id: I46e05a7a3432733976760bbf1c5deb4f7610db11
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 9 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/65/13665/1

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 17f40b9..c216f3b 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -828,16 +828,15 @@
        return mgcp->actual.endpoint_domain_name[0] ? 
mgcp->actual.endpoint_domain_name : "mgw";
 }

-const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp)
+static char *_mgcp_client_name_append_domain(const struct mgcp_client *mgcp, 
char *name)
 {
        static char endpoint[MGCP_ENDPOINT_MAXLEN];
        int rc;

-#define RTPBRIDGE_WILDCARD_FMT "rtpbridge/*@%s"
-       rc = snprintf(endpoint, sizeof(endpoint), RTPBRIDGE_WILDCARD_FMT, 
mgcp_client_endpoint_domain(mgcp));
+       rc = snprintf(endpoint, sizeof(endpoint), "%s@%s", name, 
mgcp_client_endpoint_domain(mgcp));
        if (rc > sizeof(endpoint) - 1) {
-               LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum length 
of %zu: '" RTPBRIDGE_WILDCARD_FMT "'\n",
-                    sizeof(endpoint) - 1, mgcp_client_endpoint_domain(mgcp));
+               LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum length 
of %zu: '%s@%s'\n",
+                    sizeof(endpoint) - 1, name, 
mgcp_client_endpoint_domain(mgcp));
                return NULL;
        }
        if (rc < 1) {
@@ -847,6 +846,11 @@
        return endpoint;
 }

+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp)
+{
+       return _mgcp_client_name_append_domain(mgcp, "rtpbridge/*");
+}
+
 struct mgcp_response_pending * mgcp_client_pending_add(
                                        struct mgcp_client *mgcp,
                                        mgcp_trans_id_t trans_id,

--
To view, visit https://gerrit.osmocom.org/13665
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I46e05a7a3432733976760bbf1c5deb4f7610db11
Gerrit-Change-Number: 13665
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <[email protected]>

Reply via email to