<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13815">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm48_decode_bcd_number2(): fix input len check<br><br>The input_len argument for gsm48_decode_bcd_number2() includes the BCD length<br>*and* the length byte itself, so add the missing +1.<br><br>Also clarify the API doc for the input_len argument.<br><br>Change-Id: I87599641325c04aae2be224ec350b1a145039528<br>---<br>M src/gsm/gsm48_ie.c<br>1 file changed, 3 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/15/13815/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c</span><br><span>index 049f5dc..0e5f253 100644</span><br><span>--- a/src/gsm/gsm48_ie.c</span><br><span>+++ b/src/gsm/gsm48_ie.c</span><br><span>@@ -80,7 +80,7 @@</span><br><span>  * \param[out] output  Caller-provided output buffer.</span><br><span>  * \param[in] output_len  sizeof(output).</span><br><span>  * \param[in] bcd_lv  Length-Value part of to-be-decoded IE.</span><br><span style="color: hsl(0, 100%, 40%);">- * \param[in] input_len  Size of the buffer to read the IE from.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] input_len  Size of the bcd_lv buffer for bounds checking.</span><br><span>  * \param[in] h_len  Length of an optional header between L and V parts.</span><br><span>  * \return 0 in case of success, negative on error. Errors checked: no or too little input data, no or too little</span><br><span>  * output buffer size, IE length exceeds input data size, decoded number exceeds size of the output buffer. The output</span><br><span>@@ -97,7 +97,8 @@</span><br><span>     if (input_len < 1)</span><br><span>                return -EIO;</span><br><span>         len = bcd_lv[0];</span><br><span style="color: hsl(0, 100%, 40%);">-        if (input_len < len)</span><br><span style="color: hsl(120, 100%, 40%);">+       /* len + 1: the BCD length plus the length byte itself must fit in the input buffer. */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (input_len < len + 1)</span><br><span>          return -EIO;</span><br><span>         return gsm48_decode_bcd_number(output, output_len, bcd_lv, h_len);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13815">change 13815</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/13815"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I87599641325c04aae2be224ec350b1a145039528 </div>
<div style="display:none"> Gerrit-Change-Number: 13815 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>