Adjust strncpy sizes
When building under bitbake with the latest openbmc, we get compile
warnings such as these:
```
| ../git/sections/cper-section-nvidia.c: In function 'ir_section_nvidia_to_cper':
| ../git/sections/cper-section-nvidia.c:67:9: error: '__builtin_strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
| 67 | strncpy(section_cper->Signature,
```
Using `strncpy` on its own is unsafe because a string too long will
end up in the destination buffer without NUL termination. Adjust
the strncpy to be one shorter than the buffer and force the trailing
byte to be a NUL.
Repeat this pattern for all `strncpy` calls.
Change-Id: I45c630733f0138d2b089a60f698d75e1c09de9e2
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/ir-parse.c b/ir-parse.c
index 0287337..517de45 100644
--- a/ir-parse.c
+++ b/ir-parse.c
@@ -240,7 +240,8 @@
json_object_object_get(section_descriptor_ir, "fruText");
if (fru_text != NULL) {
strncpy(descriptor->FruString, json_object_get_string(fru_text),
- 20);
+ sizeof(descriptor->FruString) - 1);
+ descriptor->FruString[sizeof(descriptor->FruString) - 1] = '\0';
}
}