From 80f642a0a4d373aeb958cb1d06b5b8fd102282d7 Mon Sep 17 00:00:00 2001 From: phdussud Date: Sat, 19 Jun 2021 12:39:25 -0700 Subject: [PATCH] Fix a buffer overflow per code review --- src/dirtyJtag.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dirtyJtag.cpp b/src/dirtyJtag.cpp index 9f9796c..74c562f 100644 --- a/src/dirtyJtag.cpp +++ b/src/dirtyJtag.cpp @@ -196,7 +196,7 @@ int DirtyJtag::writeTMS(uint8_t *tms, int len, bool flush_buffer) buf[buffer_idx++] = CMD_SETSIG; buf[buffer_idx++] = mask; buf[buffer_idx++] = val | SIG_TCK; - if ((buffer_idx + 7) >= sizeof(buf) || (i == len - 1)) { + if ((buffer_idx + 9) >= sizeof(buf) || (i == len - 1)) { //flush the buffer if (i == len - 1) { //insert tck falling edge @@ -209,7 +209,7 @@ int DirtyJtag::writeTMS(uint8_t *tms, int len, bool flush_buffer) buf, buffer_idx, &actual_length, 1000); if (ret < 0) { - cerr << "toggleClk: usb bulk write failed " << ret << endl; + cerr << "writeTMS: usb bulk write failed " << ret << endl; return -EXIT_FAILURE; } buffer_idx = 0;