diff options
author | Stefan Mahr <stefan.mahr@sphairon.com> | 2013-03-09 17:50:54 +0100 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2013-03-13 12:36:57 +0000 |
commit | 02192f6b8c63d740a551e371441d85d59930e65c (patch) | |
tree | 1d9e0df98a23f63e798be095de4afc5b3ea077df /src/jtag/drivers/opendous.c | |
parent | 9b6de72c2ba149ac6f3e11d6d0dd3030bf7b19f9 (diff) |
jtag: opendous: fix tap buffer overflow
Appending bits to TAP buffer doesn't check if there's enough space left.
This patch adds this check to fix TAP overflow error.
Change-Id: If80d5ab4a24983ad24f3cab31f9676d1590ebf5d
Signed-off-by: Stefan Mahr <stefan.mahr@sphairon.com>
Reviewed-on: http://openocd.zylin.com/1216
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/jtag/drivers/opendous.c')
-rw-r--r-- | src/jtag/drivers/opendous.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index b13cbe05..efb6cf25 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -482,8 +482,9 @@ void opendous_tap_init(void) void opendous_tap_ensure_space(int scans, int bits) { int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; + int available_bits = OPENDOUS_TAP_BUFFER_SIZE / 2 - tap_length; - if (scans > available_scans) + if ((scans > available_scans) || (bits > available_bits)) opendous_tap_execute(); } @@ -493,6 +494,8 @@ void opendous_tap_append_step(int tms, int tdi) unsigned char _tms = tms ? 1 : 0; unsigned char _tdi = tdi ? 1 : 0; + opendous_tap_ensure_space(0, 1); + int tap_index = tap_length / 4; int bits = (tap_length % 4) * 2; |