nimble/porting: Explicitly NULL terminate potential non NULL terminated 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.
This commit is contained in:
Prasad Alatkar
2020-07-22 13:06:57 +05:30
parent 7afc887873
commit 96c55c8018
+2 -1
View File
@@ -346,7 +346,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;
strncpy(omi->omi_name, cur->name, sizeof(omi->omi_name));
strncpy(omi->omi_name, cur->name, sizeof(omi->omi_name) - 1);
omi->omi_name[sizeof(omi->omi_name) - 1] = '\0';
return (cur);
}