Ver código fonte

partition: Replace strlcpy() with strncpy()

Regression in ede477ea652 for host tests only - ESP-IDF supports
strlcpy() but strlcpy & strlcat are currently no-ops in the host
tests (to avoid libbsd dependency).
Angus Gratton 4 anos atrás
pai
commit
eecf70efd0
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      components/spi_flash/partition.c

+ 2 - 2
components/spi_flash/partition.c

@@ -235,8 +235,8 @@ static esp_err_t load_partitions(void)
             item->info.encrypted = true;
         }
 
-        // note: if label in flash is not null terminated, one byte will be truncated here
-        strlcpy(item->info.label, (const char*) entry.label, sizeof(item->info.label));
+        // item->info.label is initialized by calloc, so resulting string will be null terminated
+        strncpy(item->info.label, (const char*) entry.label, sizeof(item->info.label) - 1);
 
         // add it to the list
         if (last == NULL) {