<p>1file:modules/utils/functionsc<br>
2Problem Description:Array Overflow  and  View Code Label:wsong@grandstreamcn </p>

<p>size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream_ptr)<br>
{<br>
    http_res_stream_t *stream = (http_res_stream_t *) stream_ptr;</p>

<pre><code>stream->buf = (char *) pkg_realloc(stream->buf, stream->curr_size + 
        (size * nmemb) + 1);

if (stream->buf == NULL) {
    LM_ERR("cannot allocate memory for stream\n");
    return CURLE_WRITE_ERROR;
}

memcpy(&stream->buf[stream->pos], (char *) ptr, (size * nmemb));

stream->curr_size += ((size * nmemb) + 1);
stream->pos += (size * nmemb);
</code></pre>

<p>//begin modify wsong@grandstreamcn <br>
// reason:stream->buf size begin with 0 <br>
//  stream->buf[stream->pos + 1] = '\0';<br>
stream->buf[stream->pos ] = '\0';<br>
//end modify wsong@grandstreamcn</p>

<pre><code>return size * nmemb;
</code></pre>

<p>}</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/468">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZVU7jUkSH84w4zav1yMtdguUJrGvks5pXhSvgaJpZM4HANIj.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/468"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>