1file:modules/utils/functionsc 2Problem Description:Array Overflow and View Code Label:wsong@grandstreamcn
size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream_ptr) { http_res_stream_t *stream = (http_res_stream_t *) stream_ptr;
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);
//begin modify wsong@grandstreamcn // reason:stream->buf size begin with 0 // stream->buf[stream->pos + 1] = '\0'; stream->buf[stream->pos ] = '\0'; //end modify wsong@grandstreamcn
return size * nmemb; }
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/468
This issue has been fixed on both master and stable branch 4.3. Please upgrade to the latest version.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/468#issuecomment-169614332
Closed #468.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/468#event-509600941
Does this also address issues with http_query(): failed to perform curl (23). Out of memory?
``` ERROR: utils [functions.c:57]: write_function(): cannot allocate memory for stream ERROR: utils [functions.c:150]: http_query(): failed to perform curl (23) ```
Had this happen today, not sure if it's related? Running 4.2
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/468#issuecomment-220018161