diff options
Diffstat (limited to 'src/import/hwpf/fapi2/include/error_info_defs.H')
-rw-r--r-- | src/import/hwpf/fapi2/include/error_info_defs.H | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/import/hwpf/fapi2/include/error_info_defs.H b/src/import/hwpf/fapi2/include/error_info_defs.H index 7e1803d0..2f6db98c 100644 --- a/src/import/hwpf/fapi2/include/error_info_defs.H +++ b/src/import/hwpf/fapi2/include/error_info_defs.H @@ -254,30 +254,56 @@ enum CollectTrace // NOTE - this assumes no buffer_t or variable_buffers are passed // data is converted to a uint64_t when placed into the sbe ffdc // buffer -inline fapi2::ffdc_t getFfdcData( sbeFfdc_t& i_sbeFfdc ) +inline fapi2::ffdc_t getFfdcData( sbeFfdc_t& i_sbeFfdc, bool& invalid_data ) { - fapi2::ffdc_t temp; + fapi2::ffdc_t l_ffdc; - temp.size() = static_cast<size_t>(i_sbeFfdc.size); + l_ffdc.size() = static_cast<size_t>(i_sbeFfdc.size); - if(temp.size() == EI_FFDC_SIZE_TARGET) + if(l_ffdc.size() == EI_FFDC_SIZE_TARGET) { #ifdef FAPI2_ENABLE_PLATFORM_GET_TARGET uint64_t targetData = i_sbeFfdc.data; fapi2::TargetType type = static_cast<fapi2::TargetType>(targetData >> 32); uint8_t instance = static_cast<uint8_t>(targetData & 0xFFFFFFFF); // call hostboot to get the fapi2 target reference - temp.ptr() = static_cast<void*>(getTarget<TARGET_TYPE_ALL>(type, instance)); + l_ffdc.ptr() = static_cast<void*>(getTarget<TARGET_TYPE_ALL>(type, instance)); + + if(l_ffdc.ptr() == nullptr ) + { + invalid_data = true; + } + #endif } else { - // adjust the pointer based on the data size. - temp.ptr() = static_cast<void*>(reinterpret_cast<uint8_t*>(&i_sbeFfdc.data) + - (sizeof(uint64_t) - i_sbeFfdc.size)); + // validate the size in the buffer - assumes no buffers are returned + // from sbe - + switch( i_sbeFfdc.size ) + { + // valid sizes are 1,2,4 and 8 bytes only. + case 1: + case 2: + case 4: + case 8: + // data is at least a reasonable size + break; + + default: + FAPI_ERR("Invalid data size in SBE FFDC buffer"); + invalid_data = true; + } + + if(!invalid_data) + { + // adjust the pointer based on the data size. + l_ffdc.ptr() = static_cast<void*>(reinterpret_cast<uint8_t*>(&i_sbeFfdc.data) + + (sizeof(uint64_t) - i_sbeFfdc.size)); + } } - return temp; + return l_ffdc; } #endif /// |