Skip to content

Commit

Permalink
Resources: Not a valid resource if buffer length too long
Browse files Browse the repository at this point in the history
The declared buffer length must be the same as the length of the
byte initializer list, otherwise not a valid resource descriptor.
  • Loading branch information
acpibob committed Oct 4, 2016
1 parent a002071 commit 9f76de2
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions source/components/utilities/utresrc.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -533,16 +533,19 @@ AcpiUtWalkAmlResources (
UINT8 *EndAml; UINT8 *EndAml;
UINT8 ResourceIndex; UINT8 ResourceIndex;
UINT32 Length; UINT32 Length;
ACPI_SIZE ThisAmlLength = 0;
UINT32 Offset = 0; UINT32 Offset = 0;
UINT8 EndTag[2] = {0x79, 0x00}; UINT8 EndTag[2] = {0x79, 0x00};




ACPI_FUNCTION_TRACE (UtWalkAmlResources); ACPI_FUNCTION_TRACE (UtWalkAmlResources);




/* The absolute minimum resource template is one EndTag descriptor */ /*

* The absolute minimum resource template is one EndTag descriptor.
if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) * However, we will treat a lone EndTag as just a simple buffer.
*/
if (AmlLength <= sizeof (AML_RESOURCE_END_TAG))
{ {
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
} }
Expand Down Expand Up @@ -575,8 +578,8 @@ AcpiUtWalkAmlResources (


if (UserFunction) if (UserFunction)
{ {
Status = UserFunction ( Status = UserFunction (Aml, Length, Offset,
Aml, Length, Offset, ResourceIndex, Context); ResourceIndex, Context);
if (ACPI_FAILURE (Status)) if (ACPI_FAILURE (Status))
{ {
return_ACPI_STATUS (Status); return_ACPI_STATUS (Status);
Expand All @@ -603,11 +606,19 @@ AcpiUtWalkAmlResources (
*Context = Aml; *Context = Aml;
} }


/* Check if buffer is defined to be longer than the resource length */

if (AmlLength > ThisAmlLength)
{
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
}

/* Normal exit */ /* Normal exit */


return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
} }


ThisAmlLength += Length;
Aml += Length; Aml += Length;
Offset += Length; Offset += Length;
} }
Expand Down

0 comments on commit 9f76de2

Please sign in to comment.