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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 21 17:24:56 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 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: merged
Gerrit-Change-Id: Ifcd7f691310815a31756b76067c56fba299d3ae9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
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-commits mailing list