From bbd0a3c2e25419e225028535ff03415b3f5807a7 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Tue, 14 Mar 2023 17:54:34 +0900 Subject: [PATCH] power: Use strncpy to avoid the potential problem sscanf function is detected as risky function in static analysis. Thus, change the sscanf function to strncpy function. Change-Id: I44b883eeaeea401dc251577f2bbced4f9ee8c72c Signed-off-by: Yunhee Seo --- src/power/power-boot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/power/power-boot.c b/src/power/power-boot.c index 74ec729..0f39f4a 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -48,8 +48,8 @@ static struct trans_info init_ti = { }; static struct boot_condition { - char reason[64]; - char mode[64]; + char reason[128]; + char mode[128]; } bc = { "unknown", "normal" }; static guint sig_id[2] = {0, 0}; @@ -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")) - sscanf(prop->value, "%s", config_bc.reason); + strncpy(config_bc.reason, prop->value, sizeof(prop->value) - 1); else if (MATCH(prop->key, "BootMode")) - sscanf(prop->value, "%s", config_bc.mode); + strncpy(config_bc.mode, prop->value, sizeof(prop->value) - 1); } if (MATCH(bc.reason, config_bc.reason) && MATCH(bc.mode, config_bc.mode)) -- 2.7.4