Skip to content

Commit e42367d

Browse files
Adjust gitversion handling to include null terminator in length calculations. (#2309)
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
1 parent e5074a6 commit e42367d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

SConscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ base_project_h7 = {
139139
# Common autogenerated includes
140140
with open("board/obj/gitversion.h", "w") as f:
141141
version = get_version(BUILDER, BUILD_TYPE)
142-
f.write(f'extern const uint8_t gitversion[{len(version)}];\n')
143-
f.write(f'const uint8_t gitversion[{len(version)}] = "{version}";\n')
142+
f.write(f'extern const uint8_t gitversion[{len(version)+1}];\n')
143+
f.write(f'const uint8_t gitversion[{len(version)+1}] = "{version}";\n')
144144

145145
with open("board/obj/version", "w") as f:
146146
f.write(f'{get_version(BUILDER, BUILD_TYPE)}')

board/flasher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
8383
case 0xd6:
8484
COMPILE_TIME_ASSERT(sizeof(gitversion) <= USBPACKET_MAX_SIZE);
8585
memcpy(resp, gitversion, sizeof(gitversion));
86-
resp_len = sizeof(gitversion);
86+
resp_len = sizeof(gitversion) - 1U;
8787
break;
8888
// **** 0xd8: reset ST
8989
case 0xd8:

0 commit comments

Comments
 (0)