From eecf70efd0e1ec2f000b60a1149a0b4796b47c36 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 20 May 2021 09:51:29 +1000 Subject: [PATCH] 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). --- components/spi_flash/partition.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/spi_flash/partition.c b/components/spi_flash/partition.c index 39675a5da5..506afc6caa 100644 --- a/components/spi_flash/partition.c +++ b/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) {