Fix CPER generation of ASCII properties
If FRU string and CPU brand string are not ascii, they would be
generated as non UTF-8 entities, causing json parsers like nlohmann to
fail.
These properties are defined as ASCII in the UEFI 2.10 spec.
Change-Id: Iba8056bf9855c5bcf07e0267efe47fb17da245a7
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/generator/cper-generate.c b/generator/cper-generate.c
index 91eaf41..7b60848 100644
--- a/generator/cper-generate.c
+++ b/generator/cper-generate.c
@@ -146,9 +146,8 @@
//Ensure the FRU text is not null terminated early.
for (int i = 0; i < 20; i++) {
- if (descriptor->FruString[i] == 0x0) {
- descriptor->FruString[i] = rand() % 127 + 1;
- }
+ // FRU string can only be ASCII
+ descriptor->FruString[i] = rand() % 127 + 1;
//Null terminate last byte.
if (i == 19) {
diff --git a/generator/sections/gen-section-generic.c b/generator/sections/gen-section-generic.c
index 41c315f..7baf325 100644
--- a/generator/sections/gen-section-generic.c
+++ b/generator/sections/gen-section-generic.c
@@ -25,9 +25,8 @@
//Ensure CPU brand string does not terminate early.
for (int i = 0; i < 128; i++) {
UINT8 *byte = start_byte + 24 + i;
- if (*byte == 0x0) {
- *byte = rand() % 127 + 1;
- }
+ //CPU brand can only be ASCII
+ *byte = rand() % 127 + 1;
//Null terminate last byte.
if (i == 127) {