diff options
author | Corey Farrell <git@cfware.com> | 2015-04-13 07:52:01 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2015-04-13 23:29:14 -0500 |
commit | 62e95065d697691edbfc5e0897be506b313f8be7 (patch) | |
tree | 706f9cf0942788db3d944ae8f5c57e23b82fd2cf /main/manager.c | |
parent | a573b77f781e2d6722c00bc3376afd809760bfc3 (diff) |
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
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/main/manager.c b/main/manager.c index 4cfae75df..f2a516f24 100644 --- a/main/manager.c +++ b/main/manager.c @@ -6231,9 +6231,11 @@ static int get_input(struct mansession *s, char *output) 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; |