Skip to content

Commit

Permalink
hosted/jlink: Avoid stripping the copyright string located after a nu…
Browse files Browse the repository at this point in the history
…l byte

* According to Wireshark usbmon dumps, the firmware returns 112 bytes of version,
  including some copyright information after an effectively NUL-terminator.
* Use strchr() instead of index() for Windows reasons.
  • Loading branch information
ALTracer committed Nov 5, 2023
1 parent 159a47e commit 54e047b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/platforms/hosted/jlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,15 @@ static bool jlink_get_version(void)
if (version_length > sizeof(jlink.fw_version))
return false;

/* Read vesion string directly into jlink.version */
/* Read version string directly into jlink.version */
bmda_usb_transfer(bmda_probe_info.usb_link, NULL, 0, jlink.fw_version, version_length, JLINK_USB_TIMEOUT);
jlink.fw_version[version_length - 1U] = '\0'; /* Ensure null termination */

/* Replace first NUL separating platform and copyright string */
char *firstnul = strchr(jlink.fw_version, 0);
if (firstnul != NULL)
*firstnul = '\n';

DEBUG_INFO("Firmware version: %s\n", jlink.fw_version);

/* Read the hardware version if supported */
Expand Down

0 comments on commit 54e047b

Please sign in to comment.