Modify the signature of the DumpGasStruct() function to include the
buffer length parameter and to return the number of bytes parsed by
the function.
This way it becomes possible to prevent buffer overruns when dumping
Generic Address Structure's (GAS) fields in the acpiview table
parsers.
Update all existing DumpGasStruct() calls in acpiview to add the
length argument.
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
\r
@param [in] Ptr Pointer to the start of the buffer.\r
@param [in] Indent Number of spaces to indent the output.\r
+ @param [in] Length Length of the GAS structure buffer.\r
+\r
+ @retval Number of bytes parsed.\r
**/\r
-VOID\r
+UINT32\r
EFIAPI\r
DumpGasStruct (\r
IN UINT8* Ptr,\r
- IN UINT32 Indent\r
+ IN UINT32 Indent,\r
+ IN UINT32 Length\r
)\r
{\r
Print (L"\n");\r
- ParseAcpi (\r
- TRUE,\r
- Indent,\r
- NULL,\r
- Ptr,\r
- GAS_LENGTH,\r
- PARSER_PARAMS (GasParser)\r
- );\r
+ return ParseAcpi (\r
+ TRUE,\r
+ Indent,\r
+ NULL,\r
+ Ptr,\r
+ Length,\r
+ PARSER_PARAMS (GasParser)\r
+ );\r
}\r
\r
/**\r
IN UINT8* Ptr\r
)\r
{\r
- DumpGasStruct (Ptr, 2);\r
+ DumpGasStruct (Ptr, 2, GAS_LENGTH);\r
}\r
\r
/**\r
\r
@param [in] Ptr Pointer to the start of the buffer.\r
@param [in] Indent Number of spaces to indent the output.\r
+ @param [in] Length Length of the GAS structure buffer.\r
+\r
+ @retval Number of bytes parsed.\r
**/\r
-VOID\r
+UINT32\r
EFIAPI\r
DumpGasStruct (\r
IN UINT8* Ptr,\r
- IN UINT32 Indent\r
+ IN UINT32 Indent,\r
+ IN UINT32 Length\r
);\r
\r
/**\r
AddrSize = (UINT32*)(Ptr + (*AddrSizeOffset));\r
while (Index < (*GasCount)) {\r
PrintFieldName (4, L"BaseAddressRegister");\r
- DumpGasStruct (DataPtr, 4);\r
+ DumpGasStruct (DataPtr, 4, GAS_LENGTH);\r
PrintFieldName (4, L"Address Size");\r
Print (L"0x%x\n", AddrSize[Index]);\r
DataPtr += GAS_LENGTH;\r