Project "FreeSWITCH Source" received a push.

branch: master updated

       via: e8a1055854bb4cc7037f3be434e261280714dfdf (commit)
      from: 3116334d277b0f69305434388bd56f32ae1cb2e6 (commit)


= COMMIT LOG ===========================================================
committer: Anthony Minessale
comments: 
ESL-56 null terminate buffer after reading from the socket to prevent cross-over to old data that confuses the parser and throws off framing. (regression from 2081bf97b9836f5299c22edbb1ead077842ea2bc)

diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c
index 078c5de..cd103ec 100644
--- a/libs/esl/src/esl.c
+++ b/libs/esl/src/esl.c
@@ -949,15 +949,18 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
 	while(!revent && handle->connected) {
 		esl_size_t len1;
 		
-		if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf)))) {
+		if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf) - 1))) {
 			char *data = (char *) handle->socket_buf;
 			char *p, *e;
+
+			*(data + len1) = '\0';
 			
 			esl_event_create(&revent, ESL_EVENT_CLONE);
 			revent->event_id = ESL_EVENT_SOCKET_DATA;
 			esl_event_add_header_string(revent, ESL_STACK_BOTTOM, "Event-Name", "SOCKET_DATA");
 			
 			hname = p = data;
+
 			while(p) {
 				hname = p;
 				p = NULL;
@@ -984,7 +987,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
 			break;
 		}
 
-		rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf));
+		rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1);
+		*((char *)handle->socket_buf + rrval) = '\0';
 		
 		if (rrval == 0) {
 			if (++zc >= 100) {
@@ -1020,7 +1024,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
 			if (s >= len) {
 				sofar = esl_buffer_read(handle->packet_buf, body, len);
 			} else {
-				r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf));
+				r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1);
+				*((char *)handle->socket_buf + r) = '\0';
 
 				if (r < 0) {
 					strerror_r(handle->errnum, handle->err, sizeof(handle->err));
========================================================================

Summary of changes:
 libs/esl/src/esl.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630 --
FreeSWITCH Source