From 0d8cf47ee45a70223a67e068ebe7ddf04a2a04e5 Mon Sep 17 00:00:00 2001 From: The Tumultuous Unicorn Of Darkness Date: Sun, 25 Aug 2024 16:05:11 +0200 Subject: [PATCH] Fix strings truncation warnings recog_arm.c: In function 'cpuid_identify_arm': recog_arm.c:2548:9: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation] 2548 | strncpy(data->vendor_str, hw_impl->name, VENDOR_STR_MAX); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ recog_arm.c:2549:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation] 2549 | strncpy(data->brand_str, id_part->name, BRAND_STR_MAX); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ recog_arm.c:2550:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation] 2550 | strncpy(data->cpu_codename, id_part->codename, CODENAME_STR_MAX); --- libcpuid/recog_arm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcpuid/recog_arm.c b/libcpuid/recog_arm.c index 365efdd..7facfa9 100644 --- a/libcpuid/recog_arm.c +++ b/libcpuid/recog_arm.c @@ -2545,9 +2545,9 @@ int cpuid_identify_arm(struct cpu_raw_data_t* raw, struct cpu_id_t* data) const struct arm_hw_impl* hw_impl = get_cpu_implementer_from_code(data->arm.implementer); const struct arm_id_part* id_part = get_cpu_implementer_parts(hw_impl, data->arm.part_num); data->vendor = hw_impl->vendor; - strncpy(data->vendor_str, hw_impl->name, VENDOR_STR_MAX); - strncpy(data->brand_str, id_part->name, BRAND_STR_MAX); - strncpy(data->cpu_codename, id_part->codename, CODENAME_STR_MAX); + snprintf(data->vendor_str, VENDOR_STR_MAX, "%s", hw_impl->name); + snprintf(data->brand_str, BRAND_STR_MAX, "%s", id_part->name); + snprintf(data->cpu_codename, CODENAME_STR_MAX,"%s", id_part->codename); use_cpuid_scheme = (decode_arm_architecture_version_by_midr(raw, data) == false); load_arm_features(raw, data, &ext_status); if (use_cpuid_scheme)