mirror of
https://github.com/pellepl/spiffs.git
synced 2026-06-06 05:25:27 +00:00
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:
@@ -954,7 +954,8 @@ s32_t spiffs_object_create(
|
||||
oix_hdr.p_hdr.flags = 0xff & ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_USED);
|
||||
oix_hdr.type = type;
|
||||
oix_hdr.size = SPIFFS_UNDEFINED_LEN; // keep ones so we can update later without wasting this page
|
||||
strncpy((char*)oix_hdr.name, (const char*)name, SPIFFS_OBJ_NAME_LEN);
|
||||
strncpy((char*)oix_hdr.name, (const char*)name, sizeof(oix_hdr.name) - 1);
|
||||
((char*)oix_hdr.name)[sizeof(oix_hdr.name) - 1] = '\0';
|
||||
#if SPIFFS_OBJ_META_LEN
|
||||
if (meta) {
|
||||
_SPIFFS_MEMCPY(oix_hdr.meta, meta, SPIFFS_OBJ_META_LEN);
|
||||
|
||||
Reference in New Issue
Block a user