From d1cdf39aebe56a6d23a904136661f70b74f09c3e Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 29 Jun 2023 15:25:15 +0900 Subject: [PATCH] power: Remove unsafe function To resolve build warning, strncpy is replaced by snprintf. Change-Id: I780b09d61807f889991c89766c3560c097bc509b Signed-off-by: Yunhee Seo --- src/power/power-boot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/power/power-boot.c b/src/power/power-boot.c index ca39916..b9b1fc7 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -159,9 +159,9 @@ static int parse_matching_boot_condition(const struct parse_result *result, void SYS_G_LIST_FOREACH(result->props, elem, prop) { if (MATCH(prop->key, "BootReason")) - strncpy(config_bc.reason, prop->value, sizeof(prop->value) - 1); + snprintf(config_bc.reason, sizeof(config_bc.reason), "%s", prop->value); else if (MATCH(prop->key, "BootMode")) - strncpy(config_bc.mode, prop->value, sizeof(prop->value) - 1); + snprintf(config_bc.mode, sizeof(config_bc.mode), "%s", prop->value); } if (MATCH(bc.reason, config_bc.reason) && MATCH(bc.mode, config_bc.mode)) -- 2.7.4