Skip to content

Commit

Permalink
nimble/porting: Explicitly NULL terminate potential non NULL terminat…
Browse files Browse the repository at this point in the history
…ed string buffer

os_mempool.c: Using strncpy, buffer will not be NULL terminated if size of
source string is same as buffer size. Explicitly added NULL character at the
end.
  • Loading branch information
prasad-alatkar authored and ESPAbhinav committed Feb 14, 2024
1 parent 31b5f30 commit 03df51a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions porting/nimble/src/os_mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ os_mempool_info_get_next(struct os_mempool *mp, struct os_mempool_info *omi)
omi->omi_num_blocks = cur->mp_num_blocks;
omi->omi_num_free = cur->mp_num_free;
omi->omi_min_free = cur->mp_min_free;
omi->omi_name[0] = '\0';
strncat(omi->omi_name, cur->name, sizeof(omi->omi_name) - 1);
strncpy(omi->omi_name, cur->name, sizeof(omi->omi_name) - 1);
omi->omi_name[sizeof(omi->omi_name) - 1] = '\0';

return (cur);
}
Expand Down

0 comments on commit 03df51a

Please sign in to comment.