mirror of
https://github.com/acpica/acpica/
synced 2025-02-25 01:44:33 +03:00
iASL: Remove some uses of strncopy, replace with memmove
strncpy can overwrite buffers if the code is not careful. In the case of generating a module/table header, memcpy is a better implementation.
This commit is contained in:
parent
fcd68aea5d
commit
95147faefe
@ -523,6 +523,8 @@ CgWriteAmlOpcode (
|
||||
*
|
||||
* DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
|
||||
*
|
||||
* NOTE: Input strings should be validated before this function is invoked.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static void
|
||||
@ -534,6 +536,8 @@ CgWriteTableHeader (
|
||||
ACPI_COMMENT_NODE *Current;
|
||||
|
||||
|
||||
memset (&AslGbl_TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
|
||||
|
||||
/* AML filename */
|
||||
|
||||
Child = Op->Asl.Child;
|
||||
@ -552,11 +556,11 @@ CgWriteTableHeader (
|
||||
*/
|
||||
if (AcpiGbl_CaptureComments)
|
||||
{
|
||||
strncpy(AcpiGbl_TableSig, Child->Asl.Value.String, ACPI_NAME_SIZE);
|
||||
ACPI_MOVE_NAME (AcpiGbl_TableSig, Child->Asl.Value.String);
|
||||
Child->Asl.Value.String = ACPI_SIG_XXXX;
|
||||
}
|
||||
|
||||
strncpy (AslGbl_TableHeader.Signature, Child->Asl.Value.String, ACPI_NAME_SIZE);
|
||||
ACPI_MOVE_NAME (AslGbl_TableHeader.Signature, Child->Asl.Value.String);
|
||||
|
||||
/* Revision */
|
||||
|
||||
@ -573,12 +577,14 @@ CgWriteTableHeader (
|
||||
/* OEMID */
|
||||
|
||||
Child = Child->Asl.Next;
|
||||
strncpy (AslGbl_TableHeader.OemId, Child->Asl.Value.String, ACPI_OEM_ID_SIZE);
|
||||
memcpy (AslGbl_TableHeader.OemId, Child->Asl.Value.String,
|
||||
strlen (Child->Asl.Value.String));
|
||||
|
||||
/* OEM TableID */
|
||||
|
||||
Child = Child->Asl.Next;
|
||||
strncpy (AslGbl_TableHeader.OemTableId, Child->Asl.Value.String, ACPI_OEM_TABLE_ID_SIZE);
|
||||
memcpy (AslGbl_TableHeader.OemTableId, Child->Asl.Value.String,
|
||||
strlen (Child->Asl.Value.String));
|
||||
|
||||
/* OEM Revision */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user