Skip to content

Commit 61fcf99

Browse files
committed
retain strncpy, but allow trailing null; i think this is more proper based on board.h, but memcpy and removal of +1 from .h could work as well
1 parent 27b809f commit 61fcf99

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/pg/board.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ PG_REGISTER_WITH_RESET_FN(boardConfig_t, boardConfig, PG_BOARD_CONFIG, 0);
3737

3838
void pgResetFn_boardConfig(boardConfig_t *boardConfig) {
3939
if (boardInformationIsSet()) {
40-
strncpy(boardConfig->manufacturerId, getManufacturerId(), MAX_MANUFACTURER_ID_LENGTH);
41-
strncpy(boardConfig->boardName, getBoardName(), MAX_BOARD_NAME_LENGTH);
40+
strncpy(boardConfig->manufacturerId, getManufacturerId(), MAX_MANUFACTURER_ID_LENGTH + 1);
41+
strncpy(boardConfig->boardName, getBoardName(), MAX_BOARD_NAME_LENGTH + 1);
4242
boardConfig->boardInformationSet = true;
4343
} else {
4444
#if !defined(GENERIC_TARGET)
45-
strncpy(boardConfig->boardName, targetName, MAX_BOARD_NAME_LENGTH);
45+
strncpy(boardConfig->boardName, targetName, MAX_BOARD_NAME_LENGTH + 1);
4646
#if defined(TARGET_MANUFACTURER_IDENTIFIER)
47-
memcpy(boardConfig->manufacturerId, TARGET_MANUFACTURER_IDENTIFIER, MAX_MANUFACTURER_ID_LENGTH);
47+
strncpy(boardConfig->manufacturerId, TARGET_MANUFACTURER_IDENTIFIER, MAX_MANUFACTURER_ID_LENGTH + 1);
4848
#endif
4949
boardConfig->boardInformationSet = true;
5050
#else

0 commit comments

Comments
 (0)