<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/18431">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">csn1: fix csnStreamEncoder(): also check length of the choice list<br><br>Similar checks are done in csnStreamDecoder(), so better check than sorry.<br><br>Change-Id: I441c716975905a37264efc8a76df92194f39c1fb<br>---<br>M src/csn1.c<br>1 file changed, 7 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/31/18431/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/csn1.c b/src/csn1.c</span><br><span>index 3347a64..700c342 100644</span><br><span>--- a/src/csn1.c</span><br><span>+++ b/src/csn1.c</span><br><span>@@ -1802,10 +1802,16 @@</span><br><span> </span><br><span>       case CSN_CHOICE:</span><br><span>       {</span><br><span style="color: hsl(0, 100%, 40%);">-        //gint16 count = pDescr->i;</span><br><span style="color: hsl(120, 100%, 40%);">+        gint16 count = pDescr->i;</span><br><span>         guint8 i     = 0;</span><br><span>         const CSN_ChoiceElement_t* pChoice = (const CSN_ChoiceElement_t*) pDescr->descr.ptr;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        /* Make sure that the list of choice items is not empty */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (!count)</span><br><span style="color: hsl(120, 100%, 40%);">+          return ProcessError(writeIndex, "csnStreamEncoder", CSN_ERROR_IN_SCRIPT, pDescr);</span><br><span style="color: hsl(120, 100%, 40%);">+        else if (count > 255) /* We can handle up to 256 (UCHAR_MAX) selectors */</span><br><span style="color: hsl(120, 100%, 40%);">+          return ProcessError(writeIndex, "csnStreamEncoder", CSN_ERROR_IN_SCRIPT, pDescr);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>         pui8          = pui8DATA(data, pDescr->offset);</span><br><span>         i = *pui8;</span><br><span>         pChoice += i;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/18431">change 18431</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-pcu/+/18431"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I441c716975905a37264efc8a76df92194f39c1fb </div>
<div style="display:none"> Gerrit-Change-Number: 18431 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>