pellepl / spiffs

Wear-leveled SPI flash file system for embedded devices
MIT License
1.52k stars 402 forks source link

fix strncpy() boundary condition (triggers GCC 9.x warning) #262

Open karlthewex opened 4 years ago

karlthewex commented 4 years ago

There are a few strncpy() invocations that could result in a string that is not NULL-terminated.

I see the warning using SPIFFS V0.3.7

Here's a git diff showing the suggested change that was applied locally.

diff --git a/source/third_party/spiffs/spiffs_hydrogen.c b/source/third_party/spiffs/spiffs_hydrogen.c index 23c305a45..97a445f30 100644 --- a/source/third_party/spiffs/spiffs_hydrogen.c +++ b/source/third_party/spiffs/spiffs_hydrogen.c @@ -856,6 +856,7 @@ static s32_t spiffs_stat_pix(spiffs fs, spiffs_page_ix pix, spiffs_file fh, spi s->size = objix_hdr.size == SPIFFS_UNDEFINED_LEN ? 0 : objix_hdr.size; s->pix = pix; strncpy((char )s->name, (char *)objix_hdr.name, SPIFFS_OBJ_NAME_LEN);