Fix compilation issues with strncat
Use remaining buf size as "num" argument instead of bytes to copy.
Change-Id: Ie9a721fdcdde605bcdfa850b47da472db7412362
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/sections/cper-section-arm.c b/sections/cper-section-arm.c
index b56dc50..a1e9a2d 100644
--- a/sections/cper-section-arm.c
+++ b/sections/cper-section-arm.c
@@ -181,7 +181,8 @@
strlen(*desc_string) + err_info_desc_i_len <
SECTION_DESC_STRING_SIZE) {
strncat(*desc_string, err_info_desc_i,
- err_info_desc_i_len);
+ SECTION_DESC_STRING_SIZE -
+ strlen(*desc_string) - 1);
} else {
cper_print_log(
"Error: Error info description string too long, not added to description string: %s\n",
diff --git a/sections/cper-section-nvidia.c b/sections/cper-section-nvidia.c
index c75bf8a..2882ad4 100644
--- a/sections/cper-section-nvidia.c
+++ b/sections/cper-section-nvidia.c
@@ -168,7 +168,8 @@
}
int property_desc_len = strlen(property_desc);
- strncat(*desc_string, property_desc, property_desc_len);
+ strncat(*desc_string, property_desc,
+ SECTION_DESC_STRING_SIZE - strlen(*desc_string) - 1);
// We still want to get as much info as possible, just warn about truncation
if (property_desc_len + strlen(*desc_string) >=
SECTION_DESC_STRING_SIZE) {