Skip to content

Commit

Permalink
Update _mav_put_char_array to use strncpy in v0.9/v1.0 header
Browse files Browse the repository at this point in the history
  • Loading branch information
shancock884 committed Sep 25, 2023
1 parent 74d8905 commit b86a76f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions generator/C/include_v0.9/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ static inline void mav_array_assign_char(char *dest, const char *src, size_t n)
*/
static inline void _mav_put_char_array(char *buf, uint8_t wire_offset, const char *b, uint8_t array_length)
{
mav_array_memcpy(&buf[wire_offset], b, array_length);

if (b == NULL) {
memset(&buf[wire_offset], 0, array_length);
} else {
strncpy(&buf[wire_offset], b, array_length);
}
}

/*
Expand Down
7 changes: 5 additions & 2 deletions generator/C/include_v1.0/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ static inline void mav_array_assign_char(char *dest, const char *src, size_t n)
*/
static inline void _mav_put_char_array(char *buf, uint8_t wire_offset, const char *b, uint8_t array_length)
{
mav_array_memcpy(&buf[wire_offset], b, array_length);

if (b == NULL) {
memset(&buf[wire_offset], 0, array_length);
} else {
strncpy(&buf[wire_offset], b, array_length);
}
}

/*
Expand Down

0 comments on commit b86a76f

Please sign in to comment.