[asterisk-commits] Change in asterisk[master]: AMI: Fix improper handling of lines that are exactly 1025 by...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 14 11:39:01 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: AMI: Fix improper handling of lines that are exactly 1025 bytes long.
......................................................................


AMI: Fix improper handling of lines that are exactly 1025 bytes long.

When AMI receives a line that is 1025 bytes long, it sends two error
messages.  Copy the last byte in the buffer to the first postiion,
set the length to 1.

ASTERISK-20524 #close
Reported by: David M. Lee

Change-Id: Ifda403e2713b59582c715229814fd64a0733c5ea
---
M main/manager.c
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  Matt Jordan: Looks good to me, approved; Verified
  Jared K. Smith: Looks good to me, but someone else must approve



diff --git a/main/manager.c b/main/manager.c
index 4cfae75..f2a516f 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -6231,9 +6231,11 @@
 		return 1;
 	}
 	if (s->session->inlen >= maxlen) {
-		/* no crlf found, and buffer full - sorry, too long for us */
+		/* no crlf found, and buffer full - sorry, too long for us
+		 * keep the last character in case we are in the middle of a CRLF. */
 		ast_log(LOG_WARNING, "Discarding message from %s. Line too long: %.25s...\n", ast_sockaddr_stringify_addr(&s->session->addr), src);
-		s->session->inlen = 0;
+		src[0] = src[s->session->inlen - 1];
+		s->session->inlen = 1;
 		s->parsing = MESSAGE_LINE_TOO_LONG;
 	}
 	res = 0;

-- 
To view, visit https://gerrit.asterisk.org/74
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifda403e2713b59582c715229814fd64a0733c5ea
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jared K. Smith <jaredsmith at jaredsmith.net>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list