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

Matt Jordan asteriskteam at digium.com
Thu Jan 21 17:25:00 CST 2016


Matt Jordan has submitted this change and it was merged.

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(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved
  Corey Farrell: Looks good to me, but someone else must approve



diff --git a/main/asterisk.c b/main/asterisk.c
index c576c16..d99aaed 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2808,11 +2808,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/2060
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifcd7f691310815a31756b76067c56fba299d3ae9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list