From: Scott Griepentrog Date: Tue, 9 Dec 2014 20:47:05 +0000 (+0000) Subject: core: avoid possible asterisk -r crash from long id X-Git-Tag: 14.0.0-beta1~1405 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fe45f0f0aec2b8f422e992336f23fa5fbe4adbe;p=thirdparty%2Fasterisk.git core: avoid possible asterisk -r crash from long id When connecting to the remote console, an id string is first provided that consts of the hostname, pid, and version. This is parsed by the remote instance using a buffer that may be too short, and can allow a buffer overrun because it is not terminated. This patch adds termination and a larger buffer. Review: https://reviewboard.asterisk.org/r/4182/ ........ Merged revisions 429223 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@429224 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/asterisk.c b/main/asterisk.c index 1c6994280d..0a5ab13352 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -3200,7 +3200,7 @@ static int ast_el_read_history(char *filename) static void ast_remotecontrol(char *data) { - char buf[80]; + char buf[256] = ""; int res; char filename[80] = ""; char *hostname; @@ -3217,7 +3217,7 @@ static void ast_remotecontrol(char *data) signal(SIGTERM, __remote_quit_handler); signal(SIGHUP, __remote_quit_handler); - if (read(ast_consock, buf, sizeof(buf)) < 0) { + if (read(ast_consock, buf, sizeof(buf) - 1) < 0) { ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno)); return; }