server/tcl_server.c: Fix buffer overrun
The input buffer size is checked only after writing past its end. Change-Id: I6a9651c5b7d82efe338468d67bf6caca41004b01 Signed-off-by: Jimmy <nhminus@gmail.com> Reviewed-on: http://openocd.zylin.com/5352 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
@@ -199,7 +199,7 @@ static int tcl_input(struct connection *connection)
|
||||
for (i = 0; i < rlen; i++) {
|
||||
/* buffer the data */
|
||||
tclc->tc_line[tclc->tc_lineoffset] = in[i];
|
||||
if (tclc->tc_lineoffset < tclc->tc_line_size) {
|
||||
if (tclc->tc_lineoffset + 1 < tclc->tc_line_size) {
|
||||
tclc->tc_lineoffset++;
|
||||
} else if (tclc->tc_line_size >= TCL_LINE_MAX) {
|
||||
/* maximum line size reached, drop line */
|
||||
|
||||
Reference in New Issue
Block a user