From 395531cc3711e4c85efc58669256802cbdcdcfd7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 19 Aug 2010 22:23:18 +0000 Subject: [PATCH] fix by Simon Qian of vsllink cable initialization git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1831 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 3 +++ urjtag/src/tap/cable/vsllink.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 6ffc3432..94979252 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -7,6 +7,9 @@ * src/tap/cable/gpio.c (gpio_get_value): Use already cached fp rather than constantly re-opening things on the fly. + * src/tap/cable/vsllink.c (vsllink_init): Fix by Simon Qian for initialization + of internal state, and proper NUL termination of initial buffer. + 2010-08-18 Mike Frysinger * configure.ac (AC_CHECK_FUNCS): Check for _sleep. diff --git a/urjtag/src/tap/cable/vsllink.c b/urjtag/src/tap/cable/vsllink.c index d9a5f091..247597e4 100644 --- a/urjtag/src/tap/cable/vsllink.c +++ b/urjtag/src/tap/cable/vsllink.c @@ -248,6 +248,7 @@ vsllink_init (urj_cable_t *cable) return URJ_STATUS_FAIL; } data = params->data; + memset (data, 0, sizeof (*data)); if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK) { @@ -281,10 +282,10 @@ vsllink_init (urj_cable_t *cable) } /* connect to versaloon */ + in_length = 0; for (retry = 0; retry < 3; retry++) { data->usb_buffer[0] = VERSALOON_GET_INFO; - in_length = 0; result = vsllink_usb_message (params, 1, in_length, 100); if (result >= 3) break; @@ -295,7 +296,7 @@ vsllink_init (urj_cable_t *cable) return URJ_STATUS_FAIL; } - data->usb_buffer[in_length] = '\0'; + data->usb_buffer[result] = '\0'; data->usb_buffer_size = data->usb_buffer[0] + (data->usb_buffer[1] << 8); if (data->usb_buffer_size < 64) {