signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.65k stars 1.44k forks source link

Event Socket Library only parses first 65536 bytes of event #624

Open jamesabravo opened 4 years ago

jamesabravo commented 4 years ago

The Event Socket Library has an issue with Event Socket Outbound connections (and possibly inbound mode) whereby only the first 65535 bytes of a received event is processed and parsed after being received.

With master branch 50b7dedf82f4e03b79c87d3f271c3489e52d530b , the problem lies in libs/esl/src/esl.c:1277 which reads...

if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf) - 1))) {
    char *data = (char *) handle->socket_buf;

The above line takes the currently received packet, handle->packet_buf, and stores it in handle->socket_buf which is only 65536 bytes.

One solution which I'm currently using in production is to use a temporary buffer of 1M malloc'ed in the esl_recv_event() function and change the above lines to...

if ((len1 = esl_buffer_read_packet(handle->packet_buf, read_packet_buf, READ_PACKET_BUF_SIZE - 1))) {
    char *data = (char *) read_packet_buf;

I've enclosed my version of esl.c if your interested.

esl.zip

andywolk commented 4 years ago

Please make a fork of the freeswitch repo on github, create a new branch in your fork and push changes there so we could review.

jamesabravo commented 4 years ago

Added change to following branch... https://github.com/jamesabravo/freeswitch/tree/20200511-1300-esl-lib-fix

fx02 commented 2 years ago

Any chance to apply this patch to master?