<p>Joshua Colp would like Benjamin Keith Ford to <strong>review</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15036">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils.c: NULL terminate ast_base64decode_string.<br><br>With the addition of STIR/SHAKEN, the function ast_base64decode_string<br>was added for convenience since there is a lot of converting done during<br>the STIR/SHAKEN process. This function returned the decoded string for<br>you, but did not NULL terminate it, causing some issues (specifically<br>with MALLOC_DEBUG). Now, the returned string is NULL terminated, and the<br>documentation has been updated to reflect this.<br><br>Change-Id: Icdd7d05b323b0c47ff6ed43492937a03641bdcf5<br>---<br>M include/asterisk/utils.h<br>M main/utils.c<br>2 files changed, 3 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/36/15036/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h</span><br><span>index f6280eb..0ee11ee 100644</span><br><span>--- a/include/asterisk/utils.h</span><br><span>+++ b/include/asterisk/utils.h</span><br><span>@@ -267,7 +267,7 @@</span><br><span>  * \brief Same as ast_base64decode, but does the math for you and returns</span><br><span>  * a decoded string</span><br><span>  *</span><br><span style="color: hsl(0, 100%, 40%);">- * \note The returned string will need to be freed later</span><br><span style="color: hsl(120, 100%, 40%);">+ * \note The returned string will need to be freed later and IS NULL terminated</span><br><span>  *</span><br><span>  * \param src The source buffer</span><br><span>  *</span><br><span>diff --git a/main/utils.c b/main/utils.c</span><br><span>index 0b6c6493..827ee2e 100644</span><br><span>--- a/main/utils.c</span><br><span>+++ b/main/utils.c</span><br><span>@@ -331,12 +331,13 @@</span><br><span>       }</span><br><span> </span><br><span>        decoded_len = (encoded_len / 4 * 3) - padding;</span><br><span style="color: hsl(0, 100%, 40%);">-  decoded_string = ast_calloc(1, decoded_len);</span><br><span style="color: hsl(120, 100%, 40%);">+  decoded_string = ast_malloc(decoded_len + 1);</span><br><span>        if (!decoded_string) {</span><br><span>               return NULL;</span><br><span>         }</span><br><span> </span><br><span>        ast_base64decode(decoded_string, src, decoded_len);</span><br><span style="color: hsl(120, 100%, 40%);">+   decoded_string[decoded_len] = '\0';</span><br><span> </span><br><span>      return (char *)decoded_string;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15036">change 15036</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.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.asterisk.org/c/asterisk/+/15036"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Icdd7d05b323b0c47ff6ed43492937a03641bdcf5 </div>
<div style="display:none"> Gerrit-Change-Number: 15036 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>