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 <[email protected]>
Gerrit-MessageType: newchange

Reply via email to