Add fixes based on test fuzzing.
diff --git a/sections/cper-section-generic.c b/sections/cper-section-generic.c
index 07f11ba..c82730b 100644
--- a/sections/cper-section-generic.c
+++ b/sections/cper-section-generic.c
@@ -86,7 +86,7 @@
//Validation bits.
section_cper->ValidFields = ir_to_bitfield(json_object_object_get(section, "validationBits"),
- 11, GENERIC_VALIDATION_BITFIELD_NAMES);
+ 13, GENERIC_VALIDATION_BITFIELD_NAMES);
//Various name/value pair fields.
section_cper->Type = (UINT8)readable_pair_to_integer(json_object_object_get(section, "processorType"));
diff --git a/sections/cper-section-ia32x64.c b/sections/cper-section-ia32x64.c
index 8c39ea8..9e79888 100644
--- a/sections/cper-section-ia32x64.c
+++ b/sections/cper-section-ia32x64.c
@@ -71,7 +71,7 @@
json_object_object_add(record_ir, "processorErrorInfo", error_info_array);
//Processor context information, of the amount described above.
- EFI_IA32_X64_PROCESSOR_CONTEXT_INFO* current_context_info = (EFI_IA32_X64_PROCESSOR_CONTEXT_INFO*)(current_error_info + 1);
+ EFI_IA32_X64_PROCESSOR_CONTEXT_INFO* current_context_info = (EFI_IA32_X64_PROCESSOR_CONTEXT_INFO*)current_error_info;
json_object* context_info_array = json_object_new_array();
for (int i=0; i<processor_context_info_num; i++)
{
@@ -523,8 +523,8 @@
//Miscellaneous numeric fields.
context_info_cper->ArraySize = (UINT16)json_object_get_uint64(json_object_object_get(context_info, "registerArraySize"));
- context_info_cper->MsrAddress = (UINT16)json_object_get_uint64(json_object_object_get(context_info, "msrAddress"));
- context_info_cper->MmRegisterAddress = (UINT16)json_object_get_uint64(json_object_object_get(context_info, "mmRegisterAddress"));
+ context_info_cper->MsrAddress = (UINT32)json_object_get_uint64(json_object_object_get(context_info, "msrAddress"));
+ context_info_cper->MmRegisterAddress = json_object_get_uint64(json_object_object_get(context_info, "mmRegisterAddress"));
//Flush header to stream.
fwrite(context_info_cper, sizeof(EFI_IA32_X64_PROCESSOR_CONTEXT_INFO), 1, out);
@@ -532,17 +532,21 @@
//Handle the register array, depending on type provided.
json_object* register_array = json_object_object_get(context_info, "registerArray");
- switch (context_info_cper->RegisterType)
+ if (context_info_cper->RegisterType == EFI_REG_CONTEXT_TYPE_IA32)
{
- case EFI_REG_CONTEXT_TYPE_IA32:
- ir_ia32x64_ia32_registers_to_cper(register_array, out);
- break;
- case EFI_REG_CONTEXT_TYPE_X64:
- ir_ia32x64_ia32_registers_to_cper(register_array, out);
- break;
- default:
- //Unknown/undefined.
- break;
+ ir_ia32x64_ia32_registers_to_cper(register_array, out);
+ }
+ else if (context_info_cper->RegisterType == EFI_REG_CONTEXT_TYPE_X64)
+ {
+ ir_ia32x64_x64_registers_to_cper(register_array, out);
+ }
+ else
+ {
+ //Unknown/structure is not defined.
+ json_object* encoded = json_object_object_get(register_array, "data");
+ char* decoded = b64_decode(json_object_get_string(encoded), json_object_get_string_len(encoded));
+ fwrite(decoded, context_info_cper->ArraySize, 1, out);
+ fflush(out);
}
//Free remaining resources.
diff --git a/sections/cper-section-pci-dev.c b/sections/cper-section-pci-dev.c
index cf4eb61..cac363d 100644
--- a/sections/cper-section-pci-dev.c
+++ b/sections/cper-section-pci-dev.c
@@ -93,7 +93,7 @@
free(section_cper);
//Begin writing register pairs.
- json_object* register_pairs = json_object_object_get(section, "registerPairs");
+ json_object* register_pairs = json_object_object_get(section, "registerDataPairs");
int num_pairs = json_object_array_length(register_pairs);
for (int i=0; i<num_pairs; i++)
{