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) {