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
2024-02-14 15:10:34 +05:30
committed by Abhinav Kudnar
parent 31b5f30397
commit 03df51a35c
+2 -2
View File
@@ -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);
}