From e42367df97f1a5ea4ddb152566022c3ae4672e58 Mon Sep 17 00:00:00 2001 From: downquark7 Date: Sun, 28 Dec 2025 14:53:02 -0600 Subject: [PATCH] Adjust `gitversion` handling to include null terminator in length calculations. (#2309) Co-authored-by: Adeeb Shihadeh --- SConscript | 4 ++-- board/flasher.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SConscript b/SConscript index d03a2104..957982ca 100644 --- a/SConscript +++ b/SConscript @@ -139,8 +139,8 @@ base_project_h7 = { # Common autogenerated includes with open("board/obj/gitversion.h", "w") as f: version = get_version(BUILDER, BUILD_TYPE) - f.write(f'extern const uint8_t gitversion[{len(version)}];\n') - f.write(f'const uint8_t gitversion[{len(version)}] = "{version}";\n') + f.write(f'extern const uint8_t gitversion[{len(version)+1}];\n') + f.write(f'const uint8_t gitversion[{len(version)+1}] = "{version}";\n') with open("board/obj/version", "w") as f: f.write(f'{get_version(BUILDER, BUILD_TYPE)}') diff --git a/board/flasher.h b/board/flasher.h index 34d93520..f816abec 100644 --- a/board/flasher.h +++ b/board/flasher.h @@ -83,7 +83,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { case 0xd6: COMPILE_TIME_ASSERT(sizeof(gitversion) <= USBPACKET_MAX_SIZE); memcpy(resp, gitversion, sizeof(gitversion)); - resp_len = sizeof(gitversion); + resp_len = sizeof(gitversion) - 1U; break; // **** 0xd8: reset ST case 0xd8: