[Asterisk-code-review] main/asterisk.c: ast el read char (asterisk[11])

Mark Michelson asteriskteam at digium.com
Thu Jan 21 15:25:03 CST 2016


Mark Michelson has uploaded a new change for review.

  https://gerrit.asterisk.org/2059

Change subject: main/asterisk.c: ast_el_read_char
......................................................................

main/asterisk.c: ast_el_read_char

Make sure buf[res] is not accessed at res=-1 (buffer underrun).
Address Sanitizer will complain about this quite loudly.

ASTERISK-24801 #close

Change-Id: Ifcd7f691310815a31756b76067c56fba299d3ae9
---
M main/asterisk.c
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/59/2059/1

diff --git a/main/asterisk.c b/main/asterisk.c
index 901cee1..7745d3f 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2577,11 +2577,12 @@
 
 			console_print(buf, 0);
 
-			if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) {
+			if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (res >= 2 && buf[res-2] == '\n'))) {
 				*cp = CC_REFRESH;
 				return(1);
-			} else
+			} else {
 				lastpos = 1;
+			}
 		}
 	}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcd7f691310815a31756b76067c56fba299d3ae9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Diederik de Groot <dkgroot at talon.nl>



More information about the asterisk-code-review mailing list