Change in osmo-mgw[master]: mgcp_client: do not crash when lco/sdp can not be generated

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

dexter gerrit-no-reply at lists.osmocom.org
Mon May 10 10:13:00 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24182 )


Change subject: mgcp_client: do not crash when lco/sdp can not be generated
......................................................................

mgcp_client: do not crash when lco/sdp can not be generated

The functions add_lco and add_sdp assert when the codec string can not
be generated. This is the case when an unexpected codec is addressed in
the input parameter mgcp_msg for mgcp_msg_gen(). Even though the API
user is expected only to use the codec identifiers in mgcp_client.h the
check should not be done with an assert. Instead mgcp_msg_gen() should
just return NULL.

Change-Id: Ibb788343e0bec9c0eaf33e6e4727d4d36c100017
Related: OS#5119
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 9 insertions(+), 4 deletions(-)



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

diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index a134273..1efb666 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -1118,7 +1118,11 @@
 
 			/* Note: Use codec descriptors from enum mgcp_codecs
 			 * in mgcp_client only! */
-			OSMO_ASSERT(codec);
+			if (!codec) {
+				rc += -1;
+				continue;
+			}
+
 			rc += msgb_printf(msg, "%s", extract_codec_name(codec));
 			if (i < mgcp_msg->codecs_len - 1)
 				rc += msgb_printf(msg, ";");
@@ -1226,9 +1230,10 @@
 
 			/* Note: Use codec descriptors from enum mgcp_codecs
 			 * in mgcp_client only! */
-			OSMO_ASSERT(codec);
-
-			rc += msgb_printf(msg, "a=rtpmap:%u %s\r\n", pt, codec);
+			if (!codec)
+				rc += -1;
+			else
+				rc += msgb_printf(msg, "a=rtpmap:%u %s\r\n", pt, codec);
 		}
 	}
 

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ibb788343e0bec9c0eaf33e6e4727d4d36c100017
Gerrit-Change-Number: 24182
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210510/110bd889/attachment.htm>


More information about the gerrit-log mailing list