<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-mgw/+/24182">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">mgcp_client: do not crash when lco/sdp can not be generated<br><br>The functions add_lco and add_sdp assert when the codec string can not<br>be generated. This is the case when an unexpected codec is addressed in<br>the input parameter mgcp_msg for mgcp_msg_gen(). Even though the API<br>user is expected only to use the codec identifiers in mgcp_client.h the<br>check should not be done with an assert. Instead mgcp_msg_gen() should<br>just return NULL.<br><br>Change-Id: Ibb788343e0bec9c0eaf33e6e4727d4d36c100017<br>Related: OS#5119<br>---<br>M src/libosmo-mgcp-client/mgcp_client.c<br>1 file changed, 9 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/82/24182/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>index a134273..1efb666 100644</span><br><span>--- a/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>+++ b/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>@@ -1118,7 +1118,11 @@</span><br><span> </span><br><span>                    /* Note: Use codec descriptors from enum mgcp_codecs</span><br><span>                          * in mgcp_client only! */</span><br><span style="color: hsl(0, 100%, 40%);">-                      OSMO_ASSERT(codec);</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (!codec) {</span><br><span style="color: hsl(120, 100%, 40%);">+                         rc += -1;</span><br><span style="color: hsl(120, 100%, 40%);">+                             continue;</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                  rc += msgb_printf(msg, "%s", extract_codec_name(codec));</span><br><span>                   if (i < mgcp_msg->codecs_len - 1)</span><br><span>                              rc += msgb_printf(msg, ";");</span><br><span>@@ -1226,9 +1230,10 @@</span><br><span> </span><br><span>                  /* Note: Use codec descriptors from enum mgcp_codecs</span><br><span>                          * in mgcp_client only! */</span><br><span style="color: hsl(0, 100%, 40%);">-                      OSMO_ASSERT(codec);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                     rc += msgb_printf(msg, "a=rtpmap:%u %s\r\n", pt, codec);</span><br><span style="color: hsl(120, 100%, 40%);">+                    if (!codec)</span><br><span style="color: hsl(120, 100%, 40%);">+                           rc += -1;</span><br><span style="color: hsl(120, 100%, 40%);">+                     else</span><br><span style="color: hsl(120, 100%, 40%);">+                          rc += msgb_printf(msg, "a=rtpmap:%u %s\r\n", pt, codec);</span><br><span>           }</span><br><span>    }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-mgw/+/24182">change 24182</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-mgw/+/24182"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-mgw </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ibb788343e0bec9c0eaf33e6e4727d4d36c100017 </div>
<div style="display:none"> Gerrit-Change-Number: 24182 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>