Jelajahi Sumber

Merge branch 'bugfix/partition_remove_strlcpy' into 'master'

partition: Replace strlcpy() with strncpy()

See merge request espressif/esp-idf!13603
Angus Gratton 4 tahun lalu
induk
melakukan
535e9ea594
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  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) {