Fix strncpy truncating NUL terminating char

This fix handles the gcc's `-Wstringop-truncation` warning.

See:
<https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice>
This commit is contained in:
Carmelo Pintaudi
2021-05-16 23:22:12 +02:00
parent 514be7e23f
commit 8eb5cd3662
+2 -1
View File
@@ -1018,7 +1018,8 @@ s32_t spiffs_object_update_index_hdr(
// change name
if (name) {
strncpy((char*)objix_hdr->name, (const char*)name, SPIFFS_OBJ_NAME_LEN);
strncpy((char*)objix_hdr->name, (const char*)name, sizeof(objix_hdr->name) - 1);
((char*) objix_hdr->name)[sizeof(objix_hdr->name) - 1] = '\0';
}
#if SPIFFS_OBJ_META_LEN
if (meta) {