Change in osmo-mgw[master]: mgcp_client: error on too long conn id

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Sep 6 13:42:44 UTC 2018


Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/10750 )

Change subject: mgcp_client: error on too long conn id
......................................................................

mgcp_client: error on too long conn id

Instead of just silently truncating the conn ID if it is too long, rather
verify its length and return an error where applicable.

Adjust expected test output.

Change-Id: If2a1aab1f13e771a6705c430e3c75bd42477a23b
---
M src/libosmo-mgcp-client/mgcp_client.c
M tests/mgcp_client/mgcp_client_test.err
M tests/mgcp_client/mgcp_client_test.ok
3 files changed, 11 insertions(+), 17 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index e9d7b3f..2a8cc15 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -550,6 +550,7 @@
 				 char label, const char *line)
 {
 	char label_string[4];
+	size_t rc;
 
 	/* Detect empty parameters */
 	if (strlen(line) < 4)
@@ -562,7 +563,14 @@
 
 	/* Copy payload part of the string to destinations (the label string
 	 * is always 3 chars long) */
-	osmo_strlcpy(result, line + 3, result_len);
+	rc = osmo_strlcpy(result, line + 3, result_len);
+	if (rc >= result_len) {
+		LOGP(DLMGCP, LOGL_ERROR,
+		     "Failed to parse MGCP response (parameter label: %c):"
+		     " the received conn ID is too long: %zu, maximum is %u characters\n",
+		     label, rc, result_len - 1);
+		return -ENOSPC;
+	}
 	return 0;
 
 response_parse_failure:
diff --git a/tests/mgcp_client/mgcp_client_test.err b/tests/mgcp_client/mgcp_client_test.err
index 1d5a1a0..b20f93f 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -66,4 +66,6 @@
 DLMGCP ptmap contains illegal mapping: codec=0 maps to pt=100
 DLMGCP ptmap contains illegal mapping: codec=113 maps to pt=2
 DLMGCP ptmap contains illegal mapping: codec=0 maps to pt=100
+DLMGCP Failed to parse MGCP response (parameter label: I): the received conn ID is too long: 39, maximum is 32 characters
+DLMGCP Cannot parse MGCP response (head parameters)
 Done
diff --git a/tests/mgcp_client/mgcp_client_test.ok b/tests/mgcp_client/mgcp_client_test.ok
index aedb247..40e32ba 100644
--- a/tests/mgcp_client/mgcp_client_test.ok
+++ b/tests/mgcp_client/mgcp_client_test.ok
@@ -264,20 +264,4 @@
 a=ptime:20
 
 -----
-response cb received:
-  head.response_code = 200
-  head.trans_id = 1
-  head.conn_id = 123456789abcdef0123456789ABCDEF0
-  head.comment = OK
-  audio_port = 16002
-  audio_ip = 10.9.1.120
-  ptime = 20
-  codecs_len = 2
-  codecs[0] = 112
-  codecs[1] = 110
-  ptmap_len = 2
-  ptmap[0].codec = 112
-  ptmap[0].pt = 110
-  ptmap[1].codec = 110
-  ptmap[1].pt = 96
 Done

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If2a1aab1f13e771a6705c430e3c75bd42477a23b
Gerrit-Change-Number: 10750
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180906/c6ae75ea/attachment.htm>


More information about the gerrit-log mailing list