Skip to content

Commit

Permalink
retain strncpy, but allow trailing null; i think this is more proper …
Browse files Browse the repository at this point in the history
…based on board.h, but memcpy and removal of +1 from .h could work as well
  • Loading branch information
nerdCopter committed Feb 19, 2024
1 parent e824b75 commit 46520d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/pg/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ PG_REGISTER_WITH_RESET_FN(boardConfig_t, boardConfig, PG_BOARD_CONFIG, 0);

void pgResetFn_boardConfig(boardConfig_t *boardConfig) {
if (boardInformationIsSet()) {
strncpy(boardConfig->manufacturerId, getManufacturerId(), MAX_MANUFACTURER_ID_LENGTH);
strncpy(boardConfig->boardName, getBoardName(), MAX_BOARD_NAME_LENGTH);
strncpy(boardConfig->manufacturerId, getManufacturerId(), MAX_MANUFACTURER_ID_LENGTH + 1);
strncpy(boardConfig->boardName, getBoardName(), MAX_BOARD_NAME_LENGTH + 1);
boardConfig->boardInformationSet = true;
} else {
#if !defined(GENERIC_TARGET)
strncpy(boardConfig->boardName, targetName, MAX_BOARD_NAME_LENGTH);
strncpy(boardConfig->boardName, targetName, MAX_BOARD_NAME_LENGTH + 1);
#if defined(TARGET_MANUFACTURER_IDENTIFIER)
memcpy(boardConfig->manufacturerId, TARGET_MANUFACTURER_IDENTIFIER, MAX_MANUFACTURER_ID_LENGTH);
strncpy(boardConfig->manufacturerId, TARGET_MANUFACTURER_IDENTIFIER, MAX_MANUFACTURER_ID_LENGTH + 1);
#endif
boardConfig->boardInformationSet = true;
#else
Expand Down

0 comments on commit 46520d7

Please sign in to comment.